boost::python, returning new PyObject references

David Abrahams david.abrahams at rcn.com
Sun Jan 6 18:20:00 CET 2002


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

> Let's imagine 3 different designs, A, B and C:
>
> A]
>
> struct object_base;
>
>
> struct object: object_base
>
> struct number : private object
> {
> public:
>      using ...
>
> };
>
> mapping, sequence
>
>
>
> B]
>
> struct object_base;
>
>
> struct object: object_base
>
> struct number : private virtual object
> {
> public:
>      using ...
>
> };
>
> mapping, sequence
>
> struct object : number, sequence, mapping, ...
> { };
>
>
> C]
>
> struct object_base;
>
> struct abstract_object: public virtual object_base
> {
>      // the Abstract Object Protocol
>      ...
> };
>
> struct number: public virtual object_base
> {
>      // the Abstract Number Protocol
>      ...
> };
>
> sequence, mapping
>
>
> struct object: abstract_object, number, sequence, mapping
> {
>      // The generic object interface
>
>      ...
>
> };
>
>
> ---
>
> A] is clean but there is this matter of conversions you mentioned.
> B] is the H,F,G, base  example you came up with.
> C] is what I originally was aiming for.
>
> If A] would do it is cleanest.
>
> If we have to go for B] I can't see why it is necessarily better than C]

I guess I agree with you, now that we've considered the issues.

I like where you've gone with C], with object derived from abstract_object.
I was never very fond of the intermediate seqmap class, and it seems to be
unneeded in C]; am I right?

Before moving along, you should probably take a moment to look at
http://cxx.sourceforge.net/. The object interface is one of CXX's central
features, so it may be more fully-developed than what we have in
Boost.Python. It would be a shame to overlook something which CXX has
already handled in a superior way.

Thanks for your patient work on this project, Arnaldur!

-Dave





More information about the Cplusplus-sig mailing list