[Python-Dev] Simpler reformulation of C inheritance Q.
David Abrahams
David Abrahams" <dave@boost-consulting.com
Tue, 6 Aug 2002 01:22:52 -0400
----- Original Message -----
From: "Greg Ewing" <greg@cosc.canterbury.ac.nz>
> David Abrahams <dave@boost-consulting.com>:
>
> > > This would only handle single inheritance, but I think
> > > that's all you can have at the C level anyway, isn't
> > > it?
> >
> > 1. I'm pretty sure the answer to the above question is no
>
> Er, you mean it *is* possible to inherit from multiple
> extension types? How?
One way is by invoking the metatype with a bases tuple which includes the
extension types.
I think you can also fill in tp_bases explicitly in a new extension type,
but it's been a long time since I crawled through that code and discussed
it with Guido.
> > 2. The scheme you propose is more costly in memory and cycles than I'd
> > like
>
> It's only one memory cycle more than it takes to access
> the existing sub-structures. And it's a lot better than
> the alternative, which is doing a Python dict lookup!
When I spoke of memory, I was talking about the extra pointer per level of
inheritance.
When I spoke of cycles, I was talking about the cycles to manage that
memory (probably moot).
It's not too terrible, but I'd like it a lot better if types would just use
tp_basicsize to find the beginning of the variable stuff so we could embed
the memory in the type itself. 'Course, I've forgotten more than I knew
about that code, so I might be barking up the wrong banyan.
-Dave
-----------------------------------------------------------
David Abrahams * Boost Consulting
dave@boost-consulting.com * http://www.boost-consulting.com