[Zope-dev] New-style ExtensionClasses (Zope 2.8) -- MRO issue

Jeremy Hylton jeremy at zope.com
Fri Oct 31 13:20:44 EST 2003


> I am worried enough about breaking products that I'm inclined to go
> with option 3.
> 
> Does anybody think we ought to use the new algorithm (option 2)?

I think we should use the new algorithm.  However, I don't have any
products that I would be responsible for updating and maintaining.  I'd
be happy to help people work out problems, though.

If we were starting from scratch, the C3 algorithm would be the obvious
choice.  The Dylan linearization paper makes a pretty good argument for
it:

    The first reason for the change is that a monotonic linearization
    seems a better match for users' intuitions about how inheritance and
    linearizations work. With a monotonic linearization, it is easier to
    understand the behavior of classes when multiple inheritance is
    used, largely because behavior of instances of a class can be
    explained in terms of the direct superclasses.

The depth-first resolution order can produce un-intuitive results
because it doesn't honor local precedence order.  It also leads to
sloppy code where the same base class is mixed into the inheritance
hierarchy at multiple levels.

If we stick with a non-standard MRO, then Zope programmers will have to
learn special rules for dealing with multiple inheritance with Zope code
that don't apply to Python programming in general.  I don't see much
value in creating such a special case here.

We'd also need to implement our own MRO, maintain it, make sure it's
correct, etc.  That's a long-term maintenance burden, as opposed to a
short-term problem of updating existing code.  We can write tools to
help people update their code if it ends up being a real problem, and
they get clearer code as an added bonus.

Jeremy





More information about the Zope-Dev mailing list