Description
After some chatting on gitter, @jagerman suggested that I raise an issue here, mostly so that it can be kept track of.
This is related to #439, but has more to do with what happens in the long run when more and more packages are developed using pybind11.
Currently, opaque STL containers are most often generated with a combo of the PYBIND11_MAKE_OPAQUE
macro and a call to py::bind_vector
.
If two different modules by different developers generate the same opaque containers, an import error occurs if both modules are used together. One simple solution is to wrap the binding in try/catch blocks as shown here: https://github.com/molpopgen/opaque_test. (That example uses ccpimport to compile the code.)
However, the try/catch solution is imperfect: the name seen on the Python side depends on the import order. Further, there is the deeper problem that py::bind_vector
may optionally be invoked with py::buffer_protocol()
and that the class type returned may be further augmented via .defs
in the usual way. The possible result then is that both the name and features/behavior depend on import order, which seems less than ideal.
The gitter discussion ended with the agreement that a solution is needed and that it is not clear what that solution should look like.