Is inheritance broken?

Joshua Marshall jmarshal at mathworks.com
Wed Mar 28 14:58:47 EST 2001


Skip Montanaro <skip at pobox.com> wrote:

> Someone with more Python years under their belt will have to answer why
> Guido chose depth first instead of breadth first search for methods when
> multiple inheritance is involved.  I'm pretty sure it's a choice that can't
> be changed now, however.  There's probably too much code that relies on the
> current semantics.

A breadth-first search would be too arbitrary.  Additions of
intermediate [super]classes in the inheritance hierarchy could
drastically change the result of a method lookup.

There are other solutions to multiple-inheritance method lookup
besides depth-first searching, but DFS is easy to explain/understand/
analyse.



More information about the Python-list mailing list