Ability to pass py::array without copying from c++ to python using callback #4423
Unanswered
klimentyev
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I use py::array to pass data from Python to C++ and return data from C++ to Python without copying. I check the address in Python and C++, it's the same. All is OK.
But I wanna to pass the data from C++ to Python using a callback. I successfully created the logic: std::function object in C++ and setter for callback. In Python, I register the function by the setter as callback. The code works, but addresses of numpy array are different for C++ and Python. So there was a copy.
The signature is very simple:
std::function<void(py::array data)>
anddef callback(data)
.Is it possible to pass data without copying in this case?
Beta Was this translation helpful? Give feedback.
All reactions