[C++-sig] R: Re: Boost.Python type registry

François Duranleau duranlef at iro.umontreal.ca
Thu Oct 4 17:13:55 CEST 2007

On Thu, 4 Oct 2007, jumpjoe at fastwebnet.it wrote:

>> AFAIK, there is nothing in the API to help you there. Boost.Python doesn't
>> work directly this way internally. It provides a way to test if an
>> instance holds a given type, but nothing to return the contained type
>> info.
> Is there at least a way to get a raw pointer to the wrapped object from a
> PyObject? I think extract<> is doing it.

Neither. The only thing extract<> is "extracting" is the source object's 
type name as exposed to Python (obj->ob_type->tp_name where obj is a 
PyObject*) when reporting errors. Although with that you can maybe work 
something by registering an "inverse" mapping from Python type name to C++ 
type_info, but you would need to explicitly add entries to that registry 
each time you expose a class.

Francois Duranleau

More information about the Cplusplus-sig mailing list