[New-bugs-announce] [issue33925] builtin_function_or_method compares __self__ by identity instead of equality

Jeroen Demeyer report at bugs.python.org
Thu Jun 21 06:07:32 EDT 2018


New submission from Jeroen Demeyer <J.Demeyer at UGent.be>:

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.

----------
messages: 320148
nosy: jdemeyer
priority: normal
severity: normal
status: open
title: builtin_function_or_method compares __self__ by identity instead of equality

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33925>
_______________________________________


More information about the New-bugs-announce mailing list