[Python-Dev] flextype.c -- extended type system
David Abrahams" <email@example.com
Mon, 16 Sep 2002 14:57:01 -0400
From: "Martin v. Loewis" <firstname.lastname@example.org>
> Christian Tismer <email@example.com> writes:
> > > Christian's additions (as far as I understand them :-) are mostly
> > > intended for very esoteric situations.
> > My additions support a subset of C++ virtual methods.
> > How is that esoteric?
> Why would an extension writer ever want to do this? "Normal" extension
> types either wrap some C type, so you don't have inheritance at all,
> or some C++ type, in which case a single type method can wrap
> arbitrary virtual methods (since the VMT is done in C++).
> A real-world example would help.
Well, I want to do something like this, and I think it's for a fairly
All of my (dynamically-generated) extension classes need a piece of data
which tells them how much extra data to allocate in the variable-sized area
of their instances. This is an implementation detail which I don't want to
expose to users. Right now I have to stick it in the class' __dict__, which
not only means that it's exposed, but that users can change it at will. It
also costs me an extra lookup every time an instance of the extension class
is allocated. It would be much nicer if I could get a little data area in
the type object where I could stick this value, but right now there's no
place to put it.
Chris' patch allows me to handle the issue much more naturally. It doesn't
seem esoteric to add information to a type which doesn't live it its
__dict__. Not being able to do so makes types very different from other
David Abrahams * Boost Consulting
firstname.lastname@example.org * http://www.boost-consulting.com
Of course, that makes it esoteric by its very definition ;-)