[C++-sig] registering the same type converter in different modules with Boost.Python
Ger van Diepen
diepen at astron.nl
Mon Aug 30 09:15:56 CEST 2010
We had the same problem where one module registered converters for type
A and B and another module for type B and C. I do not know if Ralf's
solution caters for such situations with mixed types.
We ended up having a private map (part of the shared library containing
our converters), so a converter gets only registered in Boost-Python if
not contained in the map.
Cheers,
Ger
>>> "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> 8/30/2010 8:57 AM >>>
> I have to convert std::pair to python tuple in different modules
independently.
> And these modules may be used concurrently, importing the second
module
> will report an warning like "std::pair has been already registered".
A simple and clean approach is to have another basic module that
defines the std::pair conversions,
and import that from the two modules you have already.
I never import extensions directly, but wrap each in a (possibly
trivial) Python module; this has
many advantages unrelated to your original question. Then you can
simply write:
module1.py
import basic # e.g. with std::pair converters
from module1_ext import *
similar for module2.py.
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100830/8010bfcf/attachment.html>
More information about the Cplusplus-sig
mailing list