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
For example, suppose you want to pass in f64s and have some computations produce resulting f64s. One way is to allocate both in the non-Rust language and then pass one as *const inputs and the other as *mut results. This avoids the need to dealloc in Rust.
I was looking for that, too.
Thanks @mark-summerfield for providing that code snippet, it helped me a lot.
Does this approach have any disadvantages compared to allocating and deallocating the result in Rust (besides that one needs to know the size of the array in advance)?
The approach shown passes just two pointers and an int to Rust, so there's virtually no call overhead.
If the data were created in Rust and returned to Python there'd be the overhead proportional to the size of the data since Python would have to copy the returned data before Rust frees it.
For example, suppose you want to pass in f64s and have some computations produce resulting f64s. One way is to allocate both in the non-Rust language and then pass one as *const inputs and the other as *mut results. This avoids the need to dealloc in Rust.
For example, in Python:
And in Rust:
Oh, and thank you for creating this web site in the first place: I have found it very useful!
The text was updated successfully, but these errors were encountered: