I have a C++ function that returns a list of structs. Inside the struct, there are more lists of structs.
struct CameraInfo {
CamName
If one-way (from c++ to python) wrapping is enough, then you can define a direct converter from list
-- see my vector >
You could also have a method returning python::list
(which would itself contain python::list
's with your objects) which would iterate over c++ nested list and build native python list out of it, but it would only work in one case you have.
For two-way conversions, either have a look at my file (which contains both-way converters for different types) -- advantage being you get native python lists, disadvatage is copying the objects. For two-way conversion of large collections, indexing_suite
is definitely the way to go.
There is indexing_suite_v2
, which is allegedly much better, including direct support for std::list
and std::map
, though unfortunately quite badly documented (last time I looked, about 1.5 years ago) and not official part of boost::python
.