In Python3, the functools.total_ordering decorator allows one to only overload __lt__
and __eq__
to get all 6 comparison operators.
I don't get why one has to write two operators when one would be enough, namely __le__
or __ge__
, and all others would be defined accordingly :
a < b <=> not (b <= a)
a > b <=> not (a <= b)
a == b <=> (a <= b) and (b <= a)
a != b <=> (a <= b) xor (b <= a)
Is that just because xor operator does not exists natively?