On 22/09/2020 12:13, Serhiy Storchaka wrote:
Because object.__eq__ and object.__ne__ exist.
I didn't quite get the logic of this. In case anyone (not Steven) is still puzzled as I was, I think one could say: ... because tp_richcompare is filled, *so that* object.__eq__ and object.__ne__ will exist to support default (identity) object comparison.
And then __lt__, etc. get defined because, as Serhiy says, ...
If you define slot tp_richcompare in C, it is exposed as 6 methods __eq__, __ne__, __lt__, __le__, __gt__ and __ge__.
By "exposed" we mean each descriptor (PyWrapperDescrObject) points to a different C function (generated by the RICHCMP_WRAPPER macro). The function summons the tp_richcompare slot function in the left object's type, with arguments (left, right, op).
Simple (not). Jeff Allen
_______________________________________________ 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/XANM3QX3I6VHOEGVPMGIU4MMJHKJGYKA/ Code of Conduct: http://python.org/psf/codeofconduct/