boost::python, returning new PyObject references

David Abrahams david.abrahams at rcn.com
Fri Jan 4 23:22:31 CET 2002


----- Original Message -----
From: "Arnaldur Gylfason" <arnaldur at decode.is>

> > What's the point of having different C++ types, then? You could just use
> > the generic object for everything. I suppose there would be a very minor
> > speed improvement if you know that an object is in fact a list rather
> > than some generic sequence, but I don't think too many people are
> > concerned about the speed of code operating at the C++/Python boundary.
>
> The C++ types export the corresponding C API parts:
> object - PyObject_*
> sequence - PySequence
> etc.
>
> I guess maybe sequence, mapping, number should then inherit from
> object_base not object.
> The proxy should then also inherit from object.
>
> Although a list does not support the __call__ interface we could have a
> user-defined class that supports both the sequence and __call__
interfaces.
>
> I am inclined to letting sequence, mapping etc. inherit from object_base
> but supporting more combinations of interfaces:
> object and sequence , object and mapping etc.
>
> What do you think?

I think your design is more complicated and less clean than it needs to be,
because either I have failed to communicate to you how I think it should go,
or you are ignoring my suggestions.

I keep trying to push you in the direction of writing a single generic
object class with /all/ of the capabilities that are accessible through
python's generic interface (number, sequence, mapping, attribute access,
call, buffer,...), and then using private non-virtual inheritance to provide
more-specialized sequence, number, etc. interfaces. Is this suggestion
unclear to you? Do you think there's something wrong with it? I'd really
like to know.

Thanks,
Dave





More information about the Cplusplus-sig mailing list