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
How do we take large arrays of structs, say a structs that represents vec3s or other more complicated but also types made up of mostly primitives, and use them in the python side with out copying? I believe buffer protocol is the answer, and I see there's buffer protocol things in pyo3, but very little explanation of how to actually use them.
We have an array of vec3s we'd like to send to a python function callback stored in the rust side of our program. Despite being a pyclass marked struct, and indirectly allocated from the python side, it doesn't appear like we can send it directly to a python function (I guess because nested python classes in a larger class aren't themselves wrapped a py-references?). The cost for re-allocating data and destroying it constantly slows the program down by 100x->10000x, so is not acceptable. We'd like to just be able to give a view of the array of memory to the python functions, but we are struggling with how to square this with using pyo3.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
How do we take large arrays of structs, say a structs that represents vec3s or other more complicated but also types made up of mostly primitives, and use them in the python side with out copying? I believe buffer protocol is the answer, and I see there's buffer protocol things in pyo3, but very little explanation of how to actually use them.
We have an array of vec3s we'd like to send to a python function callback stored in the rust side of our program. Despite being a pyclass marked struct, and indirectly allocated from the python side, it doesn't appear like we can send it directly to a python function (I guess because nested python classes in a larger class aren't themselves wrapped a py-references?). The cost for re-allocating data and destroying it constantly slows the program down by 100x->10000x, so is not acceptable. We'd like to just be able to give a view of the array of memory to the python functions, but we are struggling with how to square this with using pyo3.
Beta Was this translation helpful? Give feedback.
All reactions