-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REF: remove Block access in the JSON writing code #41081
Changes from 4 commits
df8d226
e0f32f2
ce2f9d0
14fa6d3
2ca894b
14d1953
03ade01
aad5c32
b19fc1f
ba863f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,14 +224,6 @@ def get_values(self, dtype: DtypeObj | None = None) -> np.ndarray: | |
# expected "ndarray") | ||
return self.values # type: ignore[return-value] | ||
|
||
@final | ||
def get_block_values_for_json(self) -> np.ndarray: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think the "final" is out of date; same method on DatetimeLikeBlock There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is only a single There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or at least until a few hours ago, when your PR that changed this was merged ;) ( |
||
""" | ||
This is used in the JSON C code. | ||
""" | ||
# TODO(EA2D): reshape will be unnecessary with 2D EAs | ||
return np.asarray(self.values).reshape(self.shape) | ||
|
||
@final | ||
@cache_readonly | ||
def fill_value(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1137,6 +1137,24 @@ def iget_values(self, i: int) -> ArrayLike: | |
values = block.iget(self.blklocs[i]) | ||
return values | ||
|
||
@property | ||
def column_arrays(self) -> list[np.ndarray]: | ||
""" | ||
Used in the JSON C code to access column arrays. | ||
This optimizes compared to using `iget_values` by converting each | ||
block.values to a np.ndarray only once up front | ||
""" | ||
arrays = [np.asarray(blk.values) for blk in self.blocks] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think this will change the behavior for dt64tz There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will not change behaviour, as it is the same as I would also assume it is covered by the tests, but checking explicitly: Master:
PR:
Now, to preserve the performance improvement of #41082, I can add a check for datetimetz. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hopefully more accurate statement: i think this will entail an object-dtype conversion for dt64tz. I'm not especially bothered by this bc i think this is a good cleanup There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... which i now see you already addressed in a new commit. carry on |
||
result = [] | ||
for i in range(len(self.items)): | ||
arr = arrays[self.blknos[i]] | ||
if arr.ndim == 2: | ||
values = arr[self.blklocs[i]] | ||
else: | ||
values = arr | ||
result.append(values) | ||
return result | ||
|
||
def iset(self, loc: int | slice | np.ndarray, value: ArrayLike): | ||
""" | ||
Set new item in-place. Does not consolidate. Adds new Block if not | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you remove this assignment to
cindices
you can remove this struct member altogether - not aware of it being written to anywhere else. Might help reduce confusion over state management hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed, there are still some further things to clean up. And this
cindices
is now no longer used.