[C++-sig] same to_python_converter in multiple modules?
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Thu May 30 20:06:40 CEST 2002
--- David Abrahams <david.abrahams at rcn.com> wrote:
> These are all good questions. Right now, I think the behavior is to assert
> if you supply two to_python converters for the same type. Since conversions
> go into a global registry and since there are no criteria upon which to
> choose a to_python conversion other than the source type, it is treated as
> an error to register two converters for the same type. What would the
> most-useful behavior be? You can of course avoid multiple registrations by
> creating a common shared library (or Python module if need be) which
> registers the converter and sets a global variable to prevent multiple
> registration.
Common shared library sounds OK, but the global variable is redundant. How
about enriching the Boost.Python interface:
boost::python::to_python_converter<
boost::array<int, 3>, bpl::boost_array_to_tuple<int, 3> >(
boost::python::do_nothing_if_already_registered());
If the alternative as an assert, even that is redundant, but makes it clear
what will happen and it leaves the door open for future more sophisticated
mechanisms.
Ralf
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
More information about the Cplusplus-sig
mailing list