-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: Use PySlice_GetIndicesEx instead of custom reimplementation #7215
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
Conversation
CC @seberg |
Sounds good to me, allowing booleans in slice context seems not so bad. I think I would wait with putting this in until the dust settled on 1.11 though. |
Two of the errors (warnings) look legitimate. |
Ugh, the warnings are totally not legitimate... on py2, the first argument is typed as |
nothing a little macro magic can't solve, see e.g. nditer_pywrap.c for the same issue |
that solution could be put into the 3kcompat header if we need it more than once |
@juliantaylor: oh hey, and those |
This has the side effects of: - changing several IndexError exceptions into TypeErrors - allowing slices like `arr[False:True]` as equivalent to `arr[0:1]` (because now we're using Python's logic for interpreting slices, and Python is happy with treating bools as integers in integer contexts). It also deletes almost 100 lines of code :-). While I was at it I also cleaned up some buggy uses of PySlice_GetIndices (which is pretty broken -- e.g. the code was assuming that it sets an exception on error, but this is not true! the Python docs explicitly recommend that you never use it.)
7690de4
to
9254732
Compare
Use PySlice_GetIndicesEx instead of custom reimplementation
Thanks Nathaniel. |
This has the side effects of:
arr[False:True]
as equivalent toarr[0:1]
(because now we're using Python's logic for interpretingslices, and Python is happy with treating bools as integers in integer
contexts).
It also deletes almost 100 lines of code :-).