-
Notifications
You must be signed in to change notification settings - Fork 123
Remove unsound custom element example. #255
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
5ccf9ed
to
a8b8a33
Compare
0f91038
to
de96d81
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.
Sorry I'm so behind with reviewing at the moment! For me (and future readers), could you briefly explain what was unsound about the example being removed? Apart from that, looks good to merge; thanks again!
One problem is that we do not check the element types in Will add this to the commit message. |
5ba213a
to
d5d9b43
Compare
@aldanor Since this is the continuation of #257 by other means, I would be very interested in your perspective on @davidhewitt The |
Yes, Does |
The problem is that in the current implementation I do not "need" anything from the trait as I only reinterpret memory, but I need the trait bound to ensure that this is safe. And doing should be the moral equivalent of calling What I do just notice is that there is a blanket on impl impl<T> ToPyObject for Py<T> without any bounds. So if that is the case, I should be able to remove that bound entirely here as well. |
d5d9b43
to
d62435a
Compare
Went for a |
@aldanor Friendly ping w.r.t. #255 (comment) |
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, it's nice that we found this before releasing 😅
d62435a
to
49adb7a
Compare
@adamreichold (just a note that I didn't have time to re-read and re-think this again, but will do later today when I get back to computer) |
Looks good to me. So we enable full functionality with In all seriousness, I don't think the 'aliasing' scenario we've discussed previously is that useful anyway, as using objects in numpy arrays is quite a rare thing to start with. |
In my opinion, this bound may only look weird in the docs (e.g. if I saw it the method signature, this would leave me scratching my head for a bit - like, why did the authors put it there?). If |
While we do check the array data element during extract, we do not check the type of the individual elements and hence there is no guarantee that they are of type T or even of uniform type. But if we did check each element, Python code having a reference the (base) array could change the elements and thereby their types after our check leading to type confusion in safe Rust code.
…ct, D>. The base way to construct a PyArray containing objects in a strongly typed manner is to crate a ndarray::Array<Py<T>, D> instead of converting it into a PyArray without copying using this method.
49adb7a
to
fdb366e
Compare
Fair enough. Removed the bound. |
No description provided.