MRO theory

Clarence clarence1126 at gmail.com
Wed Apr 11 14:58:49 EDT 2007


I'm having problems creating classes because of "can't create a
consistent mro" problems.

I noticed, in a test program, that if the base class list that I
pass to type.__new__ is sorted (using default keys, so presumably
sorting by the id's of the class objects), that the problem goes away.

Now in this test, the id's (memory addresses) of the class objects
are presumably in the same order as the chronological order that
the classes were created in (since the program is simple and doesn't
delete any objects or make any temporaries). This may sound weird,
but I don't actually care what order the base classes appear in as
long as they're all there.

This makes me wonder, since I can't say I understand the theory
(I read the paper referenced in typeobject.c source, my brain
didn't _quite_ melt)
behind mro creation, if it is the case that there cannot be a
consistency problem if each class in the base list was created
after all classes that precede it in the base list.

Can any genius weigh in on this question?




More information about the Python-list mailing list