This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author iritkatriel
Recipients iritkatriel, maggyero, rhettinger
Date 2020-09-26.17:55:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The PEP that Raymond linked to says:

"Further smarts could have been added to the comparison mechanism, but this limited set of allowed "swaps" was chosen because it doesn't require the infrastructure to do any processing (negation) of return values. The choice of six special methods was made over a single (e.g. __richcmp__) method to allow the dispatching on the opcode to be performed at the level of the C implementation rather than the user-defined method."

The pseudo code you suggested assumes that the results of comparisons can be interpreted as booleans, which not always correct and makes your suggestion under-specified.  It is not easy to devise a sound and intuitive composition of boolean expressions whose semantics are user-defined. 

As an aside, I think for the boolean case it is enough that one of them is not NotImplemented, so your pseudo code should have been:

def __le__(self, other):
    result_1 = self.__lt__(other)
    result_2 = self.__eq__(other)
    if result_1 is NotImplemented and result_2 is NotImplemented:
        return NotImplemented
    return result_1 or result_2
Date User Action Args
2020-09-26 17:55:27iritkatrielsetrecipients: + iritkatriel, rhettinger, maggyero
2020-09-26 17:55:27iritkatrielsetmessageid: <>
2020-09-26 17:55:27iritkatriellinkissue39862 messages
2020-09-26 17:55:27iritkatrielcreate