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
FloatArrayRef is just a pointer and count (a "view"). Normally, functions take FloatArrayRef by value and it works well. However, for my particular interface myFunc, it wants it by shared_ptr so that the caller has a chance to implement a custom deleter (e.g., the memory comes from a piece of hardware and this interface gives myFunc the opportunity to release an acquired lock as early as possible).
I'd like to call myFunc from Python using a ndarray. I imagine it's via the buffer protocol.
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
-
pybind11 newbie here. I Googled around but haven't found a definitive answer here. I have a C++ function whose interface looks something like this:
FloatArrayRef
is just a pointer and count (a "view"). Normally, functions takeFloatArrayRef
by value and it works well. However, for my particular interfacemyFunc
, it wants it byshared_ptr
so that the caller has a chance to implement a custom deleter (e.g., the memory comes from a piece of hardware and this interface givesmyFunc
the opportunity to release an acquired lock as early as possible).I'd like to call
myFunc
from Python using andarray
. I imagine it's via the buffer protocol.What's the best practice here?
Beta Was this translation helpful? Give feedback.
All reactions