Repository navigation
GH-34787: [Python] Accept zero_copy_only=False for ChunkedArray.to_numpy - #35582
Conversation
….to_numpy Signed-off-by: Julien Jerphanion <[email protected]>
|
|
|
|
|
Thank you for the contribution @jjerphan!
Yes, I think that would be useful to add 👍 |
I would personally add it in this PR. WIll change the title to include both changes. |
| PandasOptions c_options | ||
| object values | ||
|
|
||
| if zero_copy_only: |
There was a problem hiding this comment.
nit, how about putting the if/raise statement before the cdef?
| chunked_arr = None | ||
| import gc | ||
| gc.collect() | ||
|
|
||
| # Ensure base is still valid | ||
| assert np_arr.base is not None |
There was a problem hiding this comment.
I am not sure this part is needed here, as this is not actually zero copy (the base is still set, because we concatenate on the arrow side, and then still keep this concatenated buffer alive through a capsule as the numpy array's base).
There was a problem hiding this comment.
OK, so we do not want to test the presence of np_arr.base here?
There was a problem hiding this comment.
I don't think that is needed, it's in any case not specific to this test
|
Thank you for the review, @jorisvandenbossche! I will come back to this PR when I get some bandwidth. |
…kedArray.to_numpy_zero_copy_only=False
Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Julien Jerphanion <[email protected]>
|
|
|
|
|
|
|
Thanks @jjerphan! Already merging this, so it can be included in pyarrow 13.0.0. But a follow-up PR to add |
|
After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit a485bb7. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about possible false positives for unstable benchmarks that are known to sometimes produce them. |
Rationale for this change
Addresses GH-34787.
What changes are included in this PR?
I think this proposes the minimal viable changes to have the same signature as proposed in GH-34787.
Are these changes tested?
Yes, for now, a single simple test has been introduced to test the correct behavior of
ChunkedArray.to_numpywith respect to the addition ofzero_copy_only.Comments
Looking at the signature of
pa.Array.to_numpy:arrow/python/pyarrow/array.pxi
Lines 1486 to 1512 in b211c18
I think
writablecan be added as a default-valued parameter topa.ChunkedArray.to_numpy.What do you think?