[C++-sig] Re: deriving in python from a C++ base class

David Abrahams dave at boost-consulting.com
Fri Jul 4 17:06:03 CEST 2003


Stefan Seefeld <seefeld at sympatico.ca> writes:

> Hi David,
>
> David Abrahams wrote:
>
>>>PS: by the way, I found the article you cite very useful, and I think that
>>>     it illustrates things that are not or less clearly documented in the
>>>     tutorial / reference. May be some of the text could be copied over...
>> Specific suggestions will certainly be considered.
>
> something that I'd like to understand is the relationship between the
> C++ classes / objects and the corresponding python classes / objects.

Is that covered in the paper?  If so, *specifically* which sections
of text would you like to see "copied over?"

> I noted that I can call the parent's __init__ function multiple times,
> which invokes the C++ base class constructor. It seems that way I can
> instantiate more than one base class objects. Is that a specific
> boost.python problem/feature or is that part of the python object model
> ? (It's hard to debug python, i.e. I can't log the 'this pointer' in
> python, so I only know from boost.python that there are multiple C++
> base instances)....

The fact that you can call __init__ as many times as you want is part
of the Python model.  The fact that, for a wrapped class, it creates a
C++ object each time is part of the way Boost.Python works.  It might
be possible to issue an exception when that happens but it hardly
seems worthwhile to me.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list