I have a cpp method that returns a tuple of two dimensional vectors of double values (std::tuplestd::vector<std::vector<double>, ...>. When calling the method through cppyy, I am getting a weird wrapper object representing the tuple and nested vectors. These vectors eventually need to be turned into pytorch tensors, and for that to happen I need them to first be converted to python lists (or numpy arrays). How does one convert cppyy objects to pure python objects?
Asked
Active
Viewed 23 times
0
-
According to [the documentation](https://cppyy.readthedocs.io/en/latest/python.html#pyobject), cppyy handles PyObjects transparently. You could use the NumPy C interface to construct appropriate NumPy objects while in the C++ world. – Botje Aug 17 '23 at 08:57
-
@Botje Looks like a possible solution. I would however prefer to avoid any overhead code on the C++ side, and keep the integration code on the python side. – Carpet4 Aug 17 '23 at 09:29
-
1Then please edit your question to contain an [mre] and an example of what you call "a weird wrapper object representing the tuple and nested vectors". – Botje Aug 17 '23 at 09:35