22.09.20 12:48, Steven D'Aprano пише: > Why does `object` define rich comparison dunders `__lt__` etc? > > As far as I can tell, `object.__lt__` etc always return NotImplemented. > Merely inheriting from object isn't enough to have comparisons work. So > why do they exist at all? Other "do nothing" dunders such as `__add__` > aren't defined.
Because object.__eq__ and object.__ne__ exist. If you define slot tp_richcompare in C, it is exposed as 6 methods __eq__, __ne__, __lt__, __le__, __gt__ and __ge__. It is not possible to determine that __lt__() always returns NotImplemented without running it. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/NIZUOFVCTF4LEV2KA6VNRCHHYVCD2G3Z/ Code of Conduct: http://python.org/psf/codeofconduct/