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 Dennis Sweeney
Recipients Dennis Sweeney, glyph
Date 2021-07-12.19:22:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626117776.14.0.958730800341.issue44605@roundup.psfhosted.org>
In-reply-to
Content
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)"
History
Date User Action Args
2021-07-12 19:22:56Dennis Sweeneysetrecipients: + Dennis Sweeney, glyph
2021-07-12 19:22:56Dennis Sweeneysetmessageid: <1626117776.14.0.958730800341.issue44605@roundup.psfhosted.org>
2021-07-12 19:22:56Dennis Sweeneylinkissue44605 messages
2021-07-12 19:22:56Dennis Sweeneycreate