-
Notifications
You must be signed in to change notification settings - Fork 740
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
ffi: cleanup sliceobject #1866
ffi: cleanup sliceobject #1866
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! Looks good, just one suggestion related to the deprecation...
src/types/slice.rs
Outdated
@@ -61,6 +61,7 @@ impl PySlice { | |||
let start: isize = 0; | |||
let stop: isize = 0; | |||
let step: isize = 0; | |||
#[allow(deprecated)] | |||
let r = ffi::PySlice_GetIndicesEx( |
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.
What's the recommended replacement to using PySlice_GetIndicesEx
? It would be great to remove this usage of a deprecated API...
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.
In cpython, they define a macro PySlice_GetIndicesEx
(shown below)
#define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \
PySlice_Unpack((slice), (start), (stop), (step)) < 0 ? \
((*(slicelen) = 0), -1) : \
((*(slicelen) = PySlice_AdjustIndices((length), (start), (stop), *(step))), \
0))
Which I didn't implement since currently we didn't have PySlice_Unpack
and PySlice_AdjustIndices
.
These method seems not so hard. If you like, I can also implement these.
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.
That would be great, yes please!
Given the function is deprecated in Python 3.7, and there's quite a complex condition on the macro, PySlice_Unpack
and PySlice_AdjustIndices
which suggest they were added in Python 3.6.1, I think we can only use the new macro form in Python 3.7 and up.
6c44b98
to
e67338b
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.
Looks great, thank you! If you rebase on main
it should fix the CI issues with Rust 1.55 and then we can merge 👍
e67338b
to
126df61
Compare
Perfect, thanks again! |
For #1289