Raymond Hettinger added the comment:

FWIW, the logic for tuple ordering is a bit weird due to rich comparisons.   
Each pair of elements is first checked for equality (__eq__).  Only if the 
equality comparison returns False does it call the relevant ordering operations 
(such as __lt__).   The docs get it right, "If not equal, the sequences are 
ordered the same as their first differing elements."

In short tuple ordering is different from scalar ordering because it always 
makes equality tests:
 
   a < b              calls           a.__lt__(b)

in contrast:

   (a, b) < (c, d)    is more like:   if a != c:  return a < c ...

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21873>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to