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.

classification
Title: builtin_function_or_method compares __self__ by identity instead of equality
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Instance methods compare equal when their self's are equal
View: 1617161
Assigned To: Nosy List: jdemeyer, r.david.murray, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-06-21 10:07 by jdemeyer, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg320148 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2018-06-21 10:07
Methods of Python functions compare equal if the functions are equal and if __self__ is equal:

>>> class X:
...     def __eq__(self, other): return True
...     def meth(self): pass
>>> X().meth == X().meth
True

This is because X() == X() even though X() is not X().

For extension types, we get instead:

>>> [].append == [].append
False

This is because comparison is done with "is" instead of "==". This is a needless difference.
msg320153 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-21 10:55
This is a duplicate of issue1617161.
msg320166 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2018-06-21 11:21
> This is a duplicate of issue1617161.

Well, it's really the opposite. That issue seems to be arguing that __self__ should be compared using "is" while I think it should be compared using "==".
msg320181 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-06-21 13:31
This is still a duplicate issue, though, you are just arguing for a different resolution of the other one :)
History
Date User Action Args
2022-04-11 14:59:02adminsetgithub: 78106
2018-06-21 13:31:52r.david.murraysetnosy: + r.david.murray
messages: + msg320181
2018-06-21 11:21:24jdemeyersetmessages: + msg320166
2018-06-21 10:55:07serhiy.storchakasetstatus: open -> closed

superseder: Instance methods compare equal when their self's are equal

nosy: + serhiy.storchaka
messages: + msg320153
resolution: duplicate
stage: resolved
2018-06-21 10:07:32jdemeyercreate