[Python-Dev] Comparison corner case

Tim Peters tim@digicool.com
Tue, 15 May 2001 16:22:37 -0400


Here from the tail end of a patch comment.  If you believe the illustrated
behavior is wrong, then I don't believe we gain anything from using the
tp_richcmp slot for tuples for anything other than EQ/NE testing (the gain
for the latter is that it allows EQ/NE tuple comparison to work correctly on
tuples containing elements that support only EQ/NE comparisons):

"""
BUG ALERT:  The tuple (and list) richcmp algorithm is arguably wrong,
because it won't believe there's any difference unless Py_EQ returns false
for some corresponding elements:

>>> class C:
...     def __lt__(x, y): return 1
...     __eq__ = __lt__
...
>>> C() < C()
1
>>> (C(),) < (C(),)
0
>>>

That doesn't make sense -- provided you believe the defn. of C makes sense.
"""