Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Vulcans do not approve of violence. -- Spock, "Journey to Babel", stardate 3842.4


devel / comp.lang.python / Re: Multiple inheritance and a broken super() chain

SubjectAuthor
* Re: Multiple inheritance and a broken super() chainAlan Gauld
`* Re: Multiple inheritance and a broken super() chainGreg Ewing
 `- Re: Multiple inheritance and a broken super() chainChris Angelico

1
Re: Multiple inheritance and a broken super() chain

<mailman.163.1688510035.23016.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23750&group=comp.lang.python#23750

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news-2.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: learn2pr...@gmail.com (Alan Gauld)
Newsgroups: comp.lang.python
Subject: Re: Multiple inheritance and a broken super() chain
Date: Tue, 4 Jul 2023 23:33:51 +0100
Lines: 42
Message-ID: <mailman.163.1688510035.23016.python-list@python.org>
References: <CAC-uhUARYKsk92r4BEDmDGx6wbyLZbrOeL1izwHurOUDjEbJJA@mail.gmail.com>
<CAPTjJmrf-hnPanva0pSpd121oHVum5QMKF4qwZLABJ4kUX-wrg@mail.gmail.com>
<ebebe50d-fed7-0f67-99f0-92c6532b04a0@yahoo.co.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 7u0yFNs5q9Su6JEbSVElmwTAApEQVlpxCRL0/V4IhA+w==
Cancel-Lock: sha1:EQectjzCAlSLvURTMUCTDaAjRK8= sha256:HcvCyRGR58gpy9fvF6dQQTbaT4RpbQZu+P6esq4PCZk=
Return-Path: <learn2program@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=ncqySJ2b;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'jul': 0.04; '2023': 0.07;
'angelico': 0.09; 'moved': 0.09; 'practice.': 0.09;
'programmers,': 0.09; 'supported': 0.15; '(*)': 0.16; 'c++': 0.16;
'classic': 0.16; 'flickr': 0.16; 'from:name:alan gauld': 0.16;
'legacy': 0.16; 'message-id:@yahoo.co.uk': 0.16; 'odd': 0.16;
'oop': 0.16; 'photo-blog': 0.16; 'recall': 0.16; 'redundant':
0.16; 'subject:() ': 0.16; 'subject:super': 0.16; 'url-
ip:79.170.44.132/32': 0.16; 'url-ip:79.170.44/24': 0.16; 'url-
ip:79.170/16': 0.16; 'url-ip:79/8': 0.16; 'url:alan-g': 0.16;
'url:alan_gauld': 0.16; 'url:alangauldphotos': 0.16; 'variant':
0.16; 'wrote:': 0.16; 'problem': 0.16; 'reached': 0.17; 'uses':
0.19; 'tue,': 0.19; 'url:amazon': 0.19; 'to:addr:python-list':
0.20; 'ran': 0.22; 'code': 0.23; 'to:name:python-list@python.org':
0.24; 'stuff': 0.25; 'seems': 0.26; 'object': 0.26; 'opening':
0.26; "wasn't": 0.26; 'creating': 0.27; 'chris': 0.28; 'etc':
0.28; 'folks': 0.28; 'header:User-Agent:1': 0.30; 'program': 0.31;
"doesn't": 0.32; 'execution': 0.32; 'objects': 0.32; 'python-
list': 0.32; 'received:192.168.1': 0.32; 'but': 0.32; "i'm": 0.33;
'there': 0.33; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'cases':
0.36; 'people': 0.36; 'using': 0.37; 'author': 0.37;
'received:192.168': 0.37; 'neither': 0.39; 'alan': 0.40; 'learn':
0.40; 'team': 0.60; 'url-ip:99/8': 0.61; 'experienced': 0.61;
'likely': 0.61; 'url-ip:99.86/16': 0.61; 'follow': 0.62; 'ever':
0.63; 'our': 0.64; 'involve': 0.64; 'lost': 0.64; 'top': 0.65;
'years': 0.65; 'maintenance': 0.67; 'url:author': 0.69; 'site':
0.70; 'waiting': 0.73; 'database': 0.80; 'happens': 0.84;
'based.': 0.84; 'diamond': 0.84; 'garbage': 0.84; 'happen,': 0.84;
'mi.': 0.84; 'received:mail-lf1-x133.google.com': 0.84;
'subject:inheritance': 0.84; 'url-ip:13.224/16': 0.84; 'us!': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20221208; t=1688510033; x=1691102033;
h=content-transfer-encoding:in-reply-to:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:from:from:to:cc:subject:date:message-id:reply-to;
bh=ak0MJDJD0OmWWuEAK0YZevezHiHePz0UNIExLHWCbhA=;
b=ncqySJ2bn9uOUQBFK5ElMIopnHywCszvKH1S40852tMh6bkfF3An+iGzbh0l1pKQmP
yhIqK8PUR5Cj20Ib6uzNWiKZ3Uffswg2MZgsHABPaWdS9iWPCSqVC7eG2EobMC7dLG8q
H/K6+963taU9RRrYyM6+dFEYx1BYCKvZWEsQHJYC3ZT6l3eEzPjJVgx3WehdQTWUzJiY
BGPPBX4JwjO3FjaKoqHpzZRvn1zdrmHC/aHfUa9V6G6QDK6oi+Evh6fGiwF7qBfX8bez
nN0xfmw98FYt0Yd7aUFLc1PmiXBZxw91tJPDHQ7mhZUyJ1IWEtBPpZWwO55RWVHvfxLI
/U7g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1688510033; x=1691102033;
h=content-transfer-encoding:in-reply-to:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=ak0MJDJD0OmWWuEAK0YZevezHiHePz0UNIExLHWCbhA=;
b=QMSL51g5zWvPoPBXV/1szJsZPP7MwtZNviLfQbX/ft3WADByeFyQbX1ygpiH3+vDR5
R+D9tJzT5MOKZtP5PrCgsNcRwPYOHsi5qEng1TPZLxmTxhksEIRi710ifmuVIaPYtW/a
SBHt/48sBLcDEO6GF7+Rhd73aJHqvLOIhgEoXZ8An+LztXOkxVjxBtswrIFwzPzF/lrn
Nop69GQ0WMOAUu2CABOFShKBZ26kpL56/KrR8+h4C2Gj4oZahxZ15y33blKweZOq8ZwY
d/oKDD/eJE0D3oFCfT7p3/UTDiWfhDVcPy+3EZBrjQJcnMCBIyZ52oGdwgMFhTwoin79
C7EQ==
X-Gm-Message-State: ABy/qLacTVLc3vtccffkG7oo9ecrp9uyD522hEkHibTopesEsFsCLBdK
1LRmIJeFSJGsJWtrpL1XPY9S27eTp6g=
X-Google-Smtp-Source: APBJJlH1s9qRWFDj+E3p7JpLFCcBjizyRFoUtoybwMWsZlvgsIqhjzK0OLrS4lCDJjrd+ZMjDV90kg==
X-Received: by 2002:a05:6512:33c9:b0:4fb:91c5:fd38 with SMTP id
d9-20020a05651233c900b004fb91c5fd38mr12205557lfg.0.1688510032639;
Tue, 04 Jul 2023 15:33:52 -0700 (PDT)
X-Google-Original-From: Alan Gauld <alan.gauld@yahoo.co.uk>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.12.0
Content-Language: en-GB
In-Reply-To: <CAPTjJmrf-hnPanva0pSpd121oHVum5QMKF4qwZLABJ4kUX-wrg@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <ebebe50d-fed7-0f67-99f0-92c6532b04a0@yahoo.co.uk>
X-Mailman-Original-References: <CAC-uhUARYKsk92r4BEDmDGx6wbyLZbrOeL1izwHurOUDjEbJJA@mail.gmail.com>
<CAPTjJmrf-hnPanva0pSpd121oHVum5QMKF4qwZLABJ4kUX-wrg@mail.gmail.com>
 by: Alan Gauld - Tue, 4 Jul 2023 22:33 UTC

On 03/07/2023 19:39, Chris Angelico via Python-list wrote:
> On Tue, 4 Jul 2023 at 03:39, Peter Slížik via Python-list
>> The legacy code I'm working with uses a classic diamond inheritance.

> What happens when Top is initialized twice? This seems like a problem
> waiting to happen, and when you moved to using super(), you more than
> likely simplified things and fixed things.

Slightly off topic but I wonder how many real world problems
people have experienced having the top of a diamond initialized
twice? The reason I ask is that I ran a maintenance team for
about 5 years (early 1990s) working on various OOP projects using MI;
in Lisp Flavors, C++(*) and a homebrew variant of C that supported MI.
In that time I don't recall ever having problems with top objects
being initialized twice (apart from redundant execution of code
of course).

In most cases the top object was so abstract that its init()/constructor
was only doing generic type stuff or opening database sessions/networks
etc which got lost and tidied up by garbage collectors.

So I'm curious about how big this "big problem with MI" is in
practice. I'm sure there are scenarios where it has bitten folks
but it never (or very rarely) occurred in our projects. (Of
course, being maintenance programmers, the problems may have
been ironed out before the code ever reached us! But that
wasn't usually the case...)

(*) C++ is the odd one out because it doesn't have GC, but then
neither does it have an Object superclass so very often MI in C++
does not involve creating diamonds! And especially if the MI
style is mixin based.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

Re: Multiple inheritance and a broken super() chain

<kgjrltFntr1U1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23751&group=comp.lang.python#23751

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ew...@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: Multiple inheritance and a broken super() chain
Date: Wed, 5 Jul 2023 12:26:35 +1200
Lines: 21
Message-ID: <kgjrltFntr1U1@mid.individual.net>
References: <CAC-uhUARYKsk92r4BEDmDGx6wbyLZbrOeL1izwHurOUDjEbJJA@mail.gmail.com>
<CAPTjJmrf-hnPanva0pSpd121oHVum5QMKF4qwZLABJ4kUX-wrg@mail.gmail.com>
<ebebe50d-fed7-0f67-99f0-92c6532b04a0@yahoo.co.uk>
<mailman.163.1688510035.23016.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net f6z/0l1r8162Hbur+S9eJw1B0czI5fnWwp0YyU+jw9JBaNQjrX
Cancel-Lock: sha1:xy43olVnQumx9SKg2N0BLc68Hi4= sha256:NaYxlPTNMlNcK4BXT6LOcoMKCIdfuqFVbz278k9koCQ=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <mailman.163.1688510035.23016.python-list@python.org>
 by: Greg Ewing - Wed, 5 Jul 2023 00:26 UTC

On 5/07/23 10:33 am, Alan Gauld wrote:
> (*) C++ is the odd one out because it doesn't have GC, but then
> neither does it have an Object superclass so very often MI in C++
> does not involve creating diamonds! And especially if the MI
> style is mixin based.

Even if all your mixins have empty constructors, in C++ there
is still a diamond problem if they have any data members, because
you end up with multiple copies of them.

But C++ has the concept of virtual base classes, which avoids the
diamond problem, albeit at the expense of making you explicitly
call all the base class constructors in your ancestry.

--
Greg

Re: Multiple inheritance and a broken super() chain

<mailman.165.1688518320.23016.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23753&group=comp.lang.python#23753

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Multiple inheritance and a broken super() chain
Date: Wed, 5 Jul 2023 10:51:46 +1000
Lines: 36
Message-ID: <mailman.165.1688518320.23016.python-list@python.org>
References: <CAC-uhUARYKsk92r4BEDmDGx6wbyLZbrOeL1izwHurOUDjEbJJA@mail.gmail.com>
<CAPTjJmrf-hnPanva0pSpd121oHVum5QMKF4qwZLABJ4kUX-wrg@mail.gmail.com>
<ebebe50d-fed7-0f67-99f0-92c6532b04a0@yahoo.co.uk>
<mailman.163.1688510035.23016.python-list@python.org>
<kgjrltFntr1U1@mid.individual.net>
<CAPTjJmpi2WsT4KqJe=bhMTAZxENT+t9c6BSQFiirZKdxMrY52g@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de WuCOMgPSWAgK3cqWLOqPbQKryvoWisA30ioZLEg+abew==
Cancel-Lock: sha1:cJFcVEvhug6ofvcqAQbO7lD1KRE= sha256:5koK+yStTfcVCILyDaop0QnfgepDEla2Cg7lwa5Q7DE=
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Asv7u6gs;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'jul': 0.04; "python's":
0.05; 'random': 0.05; '2023': 0.07; 'explicitly': 0.07;
'members,': 0.07; 'general,': 0.09; 'syntax': 0.15; '(*)': 0.16;
'c++': 0.16; 'chrisa': 0.16; 'classes,': 0.16; 'expense': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'gauld': 0.16; 'greg': 0.16; 'odd': 0.16; 'subject:() ': 0.16;
'subject:super': 0.16; 'void': 0.16; 'wrote:': 0.16; 'problem':
0.16; 'to:addr:python-list': 0.20; 'basically': 0.22; 'problem,':
0.22; 'object': 0.26; 'creating': 0.27; 'am,': 0.31; "doesn't":
0.32; 'concept': 0.32; 'empty': 0.32; 'python-list': 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'there': 0.33;
'same': 0.34; 'requires': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'class':
0.37; 'way': 0.38; 'two': 0.39; 'copies': 0.39; 'methods': 0.39;
'neither': 0.39; 'wed,': 0.39; 'still': 0.40; 'alan': 0.40;
'base': 0.40; 'accessing': 0.64; 'involve': 0.64; 'your': 0.64;
'back': 0.67; 'choose': 0.67; 'virtual': 0.71; 'parents': 0.76;
'seek': 0.81; 'based.': 0.84; 'cooperate': 0.84; 'diamond': 0.84;
'inherit': 0.84; 'method,': 0.84; 'mi.': 0.84;
'subject:inheritance': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20221208; t=1688518318; x=1691110318;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=e9hEQMKnc+u3MeA5OVjMTPw7JZDQbSVgL57nJRCPwQ8=;
b=Asv7u6gseJIwWHGVpjC6Nl1riojAGDp/J/YAUcERZyCu6eYB1t8sjBnZXDR0xvGcSE
/SC+PztyFRTSC7/ZQ5kpCQu4THGuA9J6ue/DFlBbevhtcJcfNRYJeWUsDK0zSrmHscNY
RkIf0KvLe4wZtX0mbu8HyR9zqM8pEBMergkv10vBpN4slZagbqaSWCAp5EXsiOwrw6as
Rzi570+GJn34WMCJKXpfS8YsDGNs5VljM0D40u5xtT6E0HKcNF0CDN6EpqMfmesVf18D
f7NbQ4X1sOp7vxqBnLIfEqcnF1trQAcOoedjzQ2HaWqLcbf5NL9JpwAiZSL5elgdye3o
duBw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1688518318; x=1691110318;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=e9hEQMKnc+u3MeA5OVjMTPw7JZDQbSVgL57nJRCPwQ8=;
b=ALQQZcmljZI90Thr7/DXXGOPiZlg7XHtDdj00psmUCPf/dRLE2Gxmt67tS1rxOJeS4
1IDB/n5hxwQIHu9d8YtZZR+E5xYDHpTuDBMtvEh1GPIU1k+9N5estkabxoJhB9JQdhYK
ydanXE5HrTAPscI3c3eCsbpyG83kBaI4AOMbPyRd47EcNVAI9xykxPZZ9JsRrna543ku
ZDYAFWwzhrOBnSKHZk+Nb80kwk/V5qNx8R3BdJrUaoJFLsL1S5Nfc+Vc+/JzqhBErHlP
BKHPhjh4ixmYSNp0DZi/b+it1L/8KGRFFOMpMDcFlXAfLEg4llUEmqhF9Gk8BWwgN4MS
gHqw==
X-Gm-Message-State: ABy/qLaa18zV5IujgaaceL50iDgoy/I3Db3z/3Ls6V8h4uRIOWv76jPf
F/Pj7zDnkcFOUtk3d1C7WznERxkM8+NMT+uMph+C+kja
X-Google-Smtp-Source: APBJJlG0SVxvI/snalLP2fWiSGysOmjj4nHFbn3TBuytC5H5rVWGWIzXmwna1H3vtaw0TT7Xfth2qsc2uLK/qt7P3Kk=
X-Received: by 2002:a17:906:eb9a:b0:988:f559:47b with SMTP id
mh26-20020a170906eb9a00b00988f559047bmr8554274ejb.31.1688518318004; Tue, 04
Jul 2023 17:51:58 -0700 (PDT)
In-Reply-To: <kgjrltFntr1U1@mid.individual.net>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmpi2WsT4KqJe=bhMTAZxENT+t9c6BSQFiirZKdxMrY52g@mail.gmail.com>
X-Mailman-Original-References: <CAC-uhUARYKsk92r4BEDmDGx6wbyLZbrOeL1izwHurOUDjEbJJA@mail.gmail.com>
<CAPTjJmrf-hnPanva0pSpd121oHVum5QMKF4qwZLABJ4kUX-wrg@mail.gmail.com>
<ebebe50d-fed7-0f67-99f0-92c6532b04a0@yahoo.co.uk>
<mailman.163.1688510035.23016.python-list@python.org>
<kgjrltFntr1U1@mid.individual.net>
 by: Chris Angelico - Wed, 5 Jul 2023 00:51 UTC

On Wed, 5 Jul 2023 at 10:31, Greg Ewing via Python-list
<python-list@python.org> wrote:
>
> On 5/07/23 10:33 am, Alan Gauld wrote:
> > (*) C++ is the odd one out because it doesn't have GC, but then
> > neither does it have an Object superclass so very often MI in C++
> > does not involve creating diamonds! And especially if the MI
> > style is mixin based.
>
> Even if all your mixins have empty constructors, in C++ there
> is still a diamond problem if they have any data members, because
> you end up with multiple copies of them.
>
> But C++ has the concept of virtual base classes, which avoids the
> diamond problem, albeit at the expense of making you explicitly
> call all the base class constructors in your ancestry.

Yeah, non-virtual MI in C++ is basically composition with a shorthand
for calling non-conflicting methods or accessing non-conflicting data
members. Point of random interest: Pike actually allows that sort of
"composition MI" but will give you back an array of all parents when
you seek a superclass's method, giving a very elegant syntax for MI.

inherit Thing1;
inherit Thing2;

void method() {
::method(); //this is actually calling an array of two methods
}

Python's way of doing it requires that every class choose to cooperate
in the MI and then be aware that they are all operating on the same
object. Pike's and C++'s can sometimes be used as composition in
disguise, but in general, MI does require proper cooperation.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor