Irit Katriel <iritkatr...@yahoo.com> added the comment:

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

----------
nosy: +iritkatriel

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

Reply via email to