Message397350
The one twist is that if type(b) is a strict subtype of type(a), then "a < b" first calls type(b).__gt__(b, a), then falls back to type(a).__lt__(a, b). Example:
>>> class Int(int):
... def __gt__(self, other):
... print("Here!")
... return int(self) > int(other)
...
...
>>> 5 < Int(6)
Here!
True
see https://github.com/python/cpython/blob/da2e673c53974641a0e13941950e7976bbda64d5/Objects/object.c#L683
So I think replacing "a.__lt__(b)" with "a < b" would be an unnecessary change in behavior, since "a < b" still has to decide which method to use.
I think instead "a.__lt__(b)" could be replaced with "type(a).__lt__(a, b)" |
|
Date |
User |
Action |
Args |
2021-07-12 19:22:56 | Dennis Sweeney | set | recipients:
+ Dennis Sweeney, glyph |
2021-07-12 19:22:56 | Dennis Sweeney | set | messageid: <1626117776.14.0.958730800341.issue44605@roundup.psfhosted.org> |
2021-07-12 19:22:56 | Dennis Sweeney | link | issue44605 messages |
2021-07-12 19:22:56 | Dennis Sweeney | create | |
|