Tim Peters added the comment:
Comparison can certainly trigger a recursion error if the sequences contain no
(or few) matching non-junk elements, but contain many "almost matching"
elements. If the sequences have lengths M and N, recursion can go as deep as
2*min(M, N) then.
Now in the test
Gregory P. Smith added the comment:
It appears to devolve into linear recursion in this case, one per each item in
one of the sequences being searched for a match, so even using a stack seems
wrong as it'd still be linear (though it would prevent the recursion depth
problem).
The mutual _fanc
Terry J. Reedy added the comment:
An obvious fix for the recursion limit error is to convert the .compare
recursion to iteration with a stack (which I could try to do), but I don't know
if the deep recursion is expected in this case, or is a bug. Tim?
--
nosy: +terry.reedy, tim.peters