-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-40642: [Python] Empty slicing an array backwards beyond the start is now empty #40682
GH-40642: [Python] Empty slicing an array backwards beyond the start is now empty #40682
Conversation
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.
Thanks for the PR!
python/pyarrow/array.pxi
Outdated
if step != 1: | ||
indices = np.arange(start, stop, step) | ||
return arrow_obj.take(indices) | ||
else: | ||
length = max(stop - start, 0) | ||
return arrow_obj.slice(start, length) |
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.
We do want to keep this part, using a slice when possible, because the slice
method is always zero-copy, while the take
method returns new data
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.
Ok, I added it back
10d63ac
to
37d4411
Compare
37d4411
to
b9df1e6
Compare
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.
Thanks for the update, looks good!
Merged in the main branch in the hope this fixes the CI
|
Thanks @LucasG0 ! |
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 75a100a. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
…is now empty (#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: #40642 * GitHub Issue: #38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
…start is now empty (apache#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: apache#40642 * GitHub Issue: apache#38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
…start is now empty (apache#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: apache#40642 * GitHub Issue: apache#38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
…start is now empty (apache#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: apache#40642 * GitHub Issue: apache#38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
…start is now empty (apache#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: apache#40642 * GitHub Issue: apache#38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
What changes are included in this PR?
_normalize_slice
now relies onslice.indices
(https://docs.python.org/3/reference/datamodel.html#slice.indices).Are these changes tested?
Yes.
Are there any user-facing changes?
Fixing wrong data returned in an edge case.