[Python-ideas] MRO local precedence ordering revisited

Chris Angelico rosuav at gmail.com
Thu Dec 10 15:32:54 EST 2015


On Fri, Dec 11, 2015 at 7:03 AM, Stephan Sahm <Stephan.Sahm at gmx.de> wrote:
> I am in fact not familiar with what precisely are all the problems the C3
> algorithm tries to solve, however my own intuitiv MRO would not be anything
> proposed so far, but:
>
> (B, mixin, A, mixin, object)
>
> or in the simpler, more trivial version
>
> (B, object, A, object)
>
> As you haven't mentioned this as a possibility at all, I guess having a
> class twice in this list produces some weird behaviour I do not know about
> yet - if someone can point out, that would be great.

In terms of people's expectations of super(), I think it would be
intolerably surprising for it to be able to call a method from *the
same* class. If your mixin has "def method(self): super().method()",
it'll call itself (once) if called from B.

> P.S.: I haven't said that I want a python 2.8, nevertheless thanks for
> pointing out that there won't be a python 2.8 (this I in fact have not known
> before)! I am familar with python 3.5 as well, however I just wanted to make
> clear where I am working and in which language the example code is runnable.

https://www.python.org/dev/peps/pep-0404/
http://blog.startifact.com/guido_no.jpg

There are some special exemptions in 2.7 (for instance, some changes
went through recently that improve security, even at the expense of
some backward compatibility), but the bar is extremely high; behaviour
has to either be recognizably buggy, or have significant security
implications (cf hash randomization and certificate checking), to be
changed in 2.7. I don't think the MRO fits either category, so any
change would be 3.x only.

As mentioned, though, your code works on 3.5/3.6 without changes and
with the same semantics.

ChrisA


More information about the Python-ideas mailing list