Good way to extract numpy arrays in a tuple to std::vector #4820
faultdiagnosistoolbox
started this conversation in
General
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 have just begun to experiment with pybind11 and have a couple of newbie questions.
I have a function in C++ that takes in a python function reference. The python function returns a tuple with two 1D numpy-arrays, e.g.
My C++ function should run the python function and then extract the elements in the numpy arrays into two std::vector (this is required). This will be done fairly often, so I don't want to do unnecessary copies or steps.
Current assumptions: a) I know elements in the tuple are numpy-arrays, and b) I know the size of the elements (below type long).
This seems to work for me:
Two questions:
Any comments or help is appreciated,
Erik
Beta Was this translation helpful? Give feedback.
All reactions