You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess you are asking specifically if this can be done without copying the values into a NumPy array and then back into the Vec? Is the Vec assumed to represent one-dimensional data?
I thought about this and I am sceptical that it is possible with a safe API. While we could mem::take that &mut Vec and turn the Vec into a &PyArray1 without copying, but it will be difficult to recover ownership of the Vec. We do stash it in the arrays base object which we could inspect and downcast. But the array itself almost surely has an elevated reference count (just passing it to a function elevates it to two) so that we cannot ensure that there are no more aliasing references to the array we are trying to destructure even if the base object (an instance of our PySliceContainer) has a reference count of one.
Would it be possible to accept any numpy ufunc as
&PyAny
and apply that to a mutable vec allocated in Rust?The text was updated successfully, but these errors were encountered: