[Python-Dev] Fw: MRO 2.2 vs 2.3

Guido van Rossum guido at python.org
Sun Oct 6 16:27:58 EDT 2002


This was forwarded to python-dev.

> From: "Robin Becker" <robin at jessikat.fsnet.co.uk>
> Newsgroups: comp.lang.python
> Sent: Sunday, October 06, 2002 3:21 PM
> Subject: MRO 2.2 vs 2.3
> 
> > Will the C3 method resolution algorithm be back ported into Python
> > 2.2.x?

No -- it's a new feature, and new features are a no-no for maintenance
releases.

> It appears from the recently updated
> > 
> > http://www.python.org/2.2.1/descrintro.html#mro
> > 
> > that this will be used in 2.3, but the PBF version will then be
> > out of step with the future.

Well, that's always going to be the case for *some* feature or
another.  I wouldn't lose sleep over future compatibility.  We may
even find that C3 doesn't work that well and switch back before 2.3 is
ever released!

If it's any consolation to you, you'd have to write a program with a
pretty, um, "wild and wonderful" inheritance lattice before this would
ever bite you.  It's also the case the the difference between the
current algorithm and C3 is pretty small; the biggest difference is
that in some extreme cases, when you write

  class C(A, B): ...

B may precede A in C.__mro__ with the 2.2 algorithm, but not with the
C3 algorithm.  (The paper about C3 referenced by descrintro.html has
some examples; in all the examples that I've verified, the 2.2
algorithm behaves the same as L*LOOPS in the paper, even though
Samuele has constructed an example where L*LOOPS is different again:
this is due to the fact that L*LOOPS merges all lists simultaneously,
while the "conservative merge" algorithm in 2.2 can only merge two
lists at a time.

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list