Simple question: How to pass a C++ class reference to a callback?

David Abrahams dave at
Wed Sep 3 15:22:36 CEST 2003

Harri Pesonen <fuerte at> writes:

> David Abrahams wrote:
>> "T. Panbru" <panbru at> writes:
>>>Try encapsulating your C++ class reference in a CObject, using:
>>>     PyObject* PyCObject_FromVoidPtr( void* cobj, void (*destr)(void *))
>>>     void* PyCObject_AsVoidPtr( PyObject* self)
>>>and so forth, to go back and forth between the C++ and Python realms.
>>>Check out the Python docs at:
>> Or use one of the high-level wrapping tools such as Boost.Python
>> ( which make this stuff much easier
>> and safer.
> Boost.Python is not 2.3 compatible yet, but it seems very good.

The CVS version is 2.3 compatible; you can download a snapshot from or you can access our
anonymous CVS or a mirror (about a day behind).

Dave Abrahams
Boost Consulting

More information about the Python-list mailing list