[C++-sig] Re: instantiating python objects within C++

David Abrahams dave at boost-consulting.com
Mon May 26 20:44:32 CEST 2003

Stefan Seefeld <seefeld at sympatico.ca> writes:

> Hi David,
> David Abrahams wrote:
>>     object FooClass
>>         = class_<Foo>("Foo", init<int, char const*>())
>>                .def( ... )
>>                ...
>>                ;
>>     object foo = FooClass(3, "hello");
>> Joel, we might want to do that example in two steps as shown above
>> just to make it crystal clear what's happening.
> yes, the 'missing link' was that I didn't understand what the above
> really meant for the python interpreter. 

The interpreter, if you mean the thing that executes Python
bytecodes, isn't running this at all.

> For example right now I'm not even instantiating that class
> explicitely, I use a callable's '()' operator. 

That's what    

               FooClass(3, "hello")


> The python interpreter then figures out that it should create the so
> defined wrapper object and wrap it around my existing foo instance.

It's not really clear to me just what you mean.

> That is something I didn't understand (and still don't in detail).
> Explaining that in greater detail would surely help, not only to use
> boost.python, but also to understand how all the magic works.

Hmm.  Well, yeah, a description of the conversion mechanisms would be
good to have.  I've been meaning to write one for a while.
Unfortunately, most of my time is currently being taken by other
(paying) work, and it's hard to justify giving that project priority
right now.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list