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
Safe wrapper for NPyIter #129
Comments
Thank you!
Since |
Thanks kngwyu! I'll let you know when I get started on this and I'll post questions here? As for the lack of examples, well I guess that just makes my job more fun.
Is your idea regarding lifetimes that a |
Yes, maybe our NpyIter looks like: struct NpyIter<'py> {
ptr: NonNull<npyffi::NpyIter>,
py: Python<'py>,
} |
Note that |
Any advice on ergonomicly handling the following parameters of
|
Also entries in op can be NULL which causes the MultiIndex to allocate a new array. |
The rust wrapper also needs to keep track of a seperate entry called the |
I'm thinking something inspired by I could use a different type for the MultiIter constructor and perhaps do something like constructor.set_flag(FlagEnum::FlagName).add_array(myfirst_pyarray).set_flag(OpFlagEnum::FlagName, true)..add_array(mysecond_pyarray).set_flag(OpFlagEnum::FlagName, true).set_flag(OpFlagEnum::AnotherFlagName, true) I also don't think there's a huge need for MultiIter and the 1D Iter to share a wrapper, as they do fundamentally behave differently. |
I'm also thinking I should avoid NumPy setting any Exceptions, and instead have it return error strings that can be passed up to the caller so that the caller can choose whether to raise an exception. |
Maybe it is what is often called the builder pattern.
PyO3 itself can handle exceptions. You don't have to worry about it.
You can use MaybeUninit but it can be difficult. |
I think we can close this issue? |
👍🏼 |
I'm evaluating using
rust-numpy
for a project that will require extensive use ofNPyIter
as I have to re-implement a number of ufuncs and need access to the broadcasting implementation.I'm currently using
np.broadcast
in Python code to implement this.Would there be any interest in making a safe wrapper for NPyIter if I built one?
Does anyone have any advice or similar wrappers I could reference? This is my first experience with writing unsafe rust code.
The text was updated successfully, but these errors were encountered: