[Python-Dev] Simpler reformulation of C inheritance Q.

David Abrahams David Abrahams" <dave@boost-consulting.com
Mon, 5 Aug 2002 09:32:51 -0400


From: "Christian Tismer" <tismer@tismer.com>


> Hi Guido:
>
> here a simpler formulation of my question:
>
> I would like to create types with overridable methods.
> This is supported by the new type system.
>
> But I'd also like to make this as fast as possible and
> therefore to avoid extra dictionary lookups for methods,
> especially if they are most likely not overridden.
>
> This would mean to create an extra meta type which creates
> types with a couple of extra slots, for caching overridden
> methods.
>
> My problem is now that type objects are already variable
> sized and cannot support slots in the metatype.
> Is there a workaround on the boilerplate, or is there
> interest in a solution?
> Any suggestion how to implement it?

I believe this is roughly the same thing I was bugging Guido about just
before Python-dev. I wanted types which acted like new-style classes, but
with room for an 'C' int to store some extra information -- namely, whether
there were multiple 'C' extension classes being used as bases. IIRC the
verdict was, "you can't do that today, but there should be a way to do it".
Also if I remember anything about my hasty analysis at the time, the
biggest challenge would be getting code which accesses types to rely on
their tp_basicsize in order to find the beginning of the variable stuff.

FWIW, I'm still interested in seeing this addressed.

Thanks,
Dave


-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave@boost-consulting.com * http://www.boost-consulting.com