-
Notifications
You must be signed in to change notification settings - Fork 113
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
make PySliceContainer
implement Sync
#469
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.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no suggestions.
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 agree. cc @ngoldbaum, I wonder if you have opinions on this?
src/slice_container.rs
Outdated
unsafe impl Send for PySliceContainer {} | ||
unsafe impl Sync for PySliceContainer {} |
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.
Shall we add some // Safety
comments here to justify (both) traits?
Forgive my lack of context here: is |
Yes, exactly that, it'll usually be |
In that case yes I agree we should ensure T is Sync. |
Thank you both for taking a look. I'll go ahead an merge this then. |
Prepares for the
pyo3
upgrade to 0.23 in #457.This contains two changes:
This implements
Sync
forPySliceContainer
which is used as the underlying backing object for Rust allocatednumpy
arrays.Since
PySliceContainer
"virtually" does hold elements of typeT
(which is cast away due to the no-generics limitation), construction is only allowed fromT
s that areSync
themselves. (Ideally we would haveunsafe impl<T: Sync> Sync for PySliceContainer<T> {}
).I think it will hand out references into that buffer in place, so we need to require all
Element
s to beSync
as well. In any case I think this could only be too strong, which would not be unsound.