[Python-Dev] Multiple inheritance from builtin (C) types [still] supported in Python3?

Guido van Rossum guido at python.org
Mon Apr 28 21:10:35 CEST 2014


On Mon, Apr 28, 2014 at 12:02 PM, Antoine Pitrou <solipsis at pitrou.net>wrote:

>
> On Mon, 28 Apr 2014 21:42:02 +0300
> Paul Sokolovsky <pmiscml at gmail.com> wrote:
> > >
> > > Basically, if two classes have compatible layouts, you can inherit
> > > from both at once.
> >
> > How is "compatible layout" defined? Or "layout" for that matter at
> > all?
>
> See Guido's answer. I don't think it's documented anywhere, but you can
> find the relevant code somewhere in Objects/typeobject.c (it's quite a
> mouthful, though :-)).
>
> (IIRC, "layout" is determined by tp_basicsize, tp_itemsize, the
> number of __slots__, and other things perhaps)
>

IIRC the actual inheritance pattern also goes into it. Two structs that
each add an identical new field to a common base class's struct should
*not* be considered compatible.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140428/cfcf411c/attachment.html>


More information about the Python-Dev mailing list