The C3 linearization algorithm for method resolution in multiple inheritance OO languages: Looking for a justification for some implementation detail According to this description of Python's method resolution order (mro), a.k.a. C3 linearization, the algorithm can be described recursively as follows:

L(O) = &lt;O&gt;
L(C) = &lt;C&gt; + merge(L(B1),..., L(Bn), &lt;B1,...,Bn&gt;)


where


O is the class from which every class inherits.
C is a class that inherits directly from B1, ..., Bn, in this order.
&lt; and &gt; are list delimiters.
+ is the list-concatenation operator.
merge merges its list arguments into a single list, in a manner to be described below.


The above can be rephrased in words (quoted from the above Python document):


  the linearization of C is the sum of C plus the merge of the linearizations of the parents and the list of the parents.


The merge algorithm is described as follows (essentially quoted from the Python document, but slightly reworded):


  Consider the head of the first list, i.e L(B1)[0]: if it is a good head, i.e. if it is not in the proper tail of any of the other lists, add it to the linearization of C, and remove it from all the lists in the merge. Otherwise, consider the head of the next list, etc. Repeat until no more classes, or no good heads. In the latter case, it is impossible to construct the merge.


The following example is given as an illustration. Suppose A inherits directly from B and C, in this order, and suppose that the linearizations of B and C are

L(B) = &lt;B, D, E, O&gt;
L(C) = &lt;C, D, F, O&gt;


Then A's linearization is

L(A) = &lt;A&gt; + merge(&lt;B,D,E,O&gt;, &lt;C,D,F,O&gt;, &lt;B,C&gt;)
     = &lt;A, B&gt; + merge(&lt;D,E,O&gt;, &lt;C,D,F,O&gt;, &lt;C&gt;)
     = &lt;A, B, C&gt; + merge(&lt;D,E,O&gt;, &lt;D,F,O&gt;)
     = &lt;A, B, C, D&gt; + merge(&lt;E,O&gt;, &lt;F,O&gt;)
     = &lt;A, B, C, D, E&gt; + merge(&lt;O&gt;, &lt;F,O&gt;)
     = &lt;A, B, C, D, E, F&gt; + merge(&lt;O&gt;, &lt;O&gt;)
     = &lt;A, B, C, D, E, F, O&gt;


My question is: in terms of the original description of the algorithm, what purpose does it serve to give the list &lt;B1,...,Bn&gt; of direct parents as an argument to merge? Will the algorithm produce different results if this argument is omitted?
Without the last list:

merge(&lt;B,D,O&gt;, &lt;C,F,O&gt;, &lt;D,O&gt;) =
  &lt;B,D,C,F,O&gt; 


With the last list:

merge(&lt;B,D,O&gt;, &lt;C,F,O&gt;, &lt;D,O&gt;, &lt;B,C,D&gt;) =
  &lt;B&gt; + merge(&lt;D,O&gt;, &lt;C,F,O&gt;, &lt;D,O&gt;, &lt;C,D&gt;) =
  &lt;B,C&gt; + merge(&lt;D,O&gt;, &lt;F,O&gt;, &lt;D,O&gt;, &lt;D&gt;) =
  &lt;B,C,D,F,O&gt;




Without the last list:

merge(&lt;B,D,C,O&gt;, &lt;C,F,O&gt;, &lt;D,O&gt;) =
  &lt;B,D,C,F,O&gt; 


With the last list:

merge(&lt;B,D,C,O&gt;, &lt;C,F,O&gt;, &lt;D,O&gt;, &lt;B,C,D&gt;) =
  &lt;B&gt; + merge(&lt;D,C,O&gt;, &lt;C,F,O&gt;, &lt;D,O&gt;, &lt;C,D&gt;) =
  no-merge




Intuitively, the last list forces the final result to be compatible with the ordering &lt;B1,...,Bn&gt;. That might change the order, or make the merge fail.