[Python-Dev] assigning to new-style-class.__name__

Samuele Pedroni pedronis@bluewin.ch
Wed, 27 Nov 2002 13:23:48 +0100

From: "Michael Hudson" <mwh@python.net>

> ...  ...   ...
>  \   /     /
>   \ /     /
>    C     D
>     \   /
>      \ /
>       E
> is it possible to rearrange the __bases__ of C in a way that doesn't
> create a conflict for C but does for E?  I haven't thought about MRO
> calculations at all, I'm afraid.

Yes, if A B (in this order in the mro) are bases of C, and also bases of D and
you swap them in C (but not D) then E's mro will become subject to an order

I haven't looked at the code, but if it checks directly for the consistency of
E's mro when you change C's bases, then there is no way to move from a
hierarchy where A precedes B in the mros to one where the two are swapped,
although the second would be legal if constructed anew piecewise from
superclasses down to subclasses.

So maybe the mros of the subclasses should be computed lazily when needed (e.g.
onthe  first - after the changes - dispatch), although this may produce
inconsistences and errors at odd times. Maybe the code is already doing that?