[Python-Dev] Equality on method objects
Armin Rigo
arigo at tunes.org
Sun Mar 9 17:02:49 CET 2008
Hi all,
In Python 2.5, I made an attempt to make equality consistent for the
various built-in and user-defined method types. I failed, though, as
explained in http://bugs.python.org/issue1617161. The outcome of this
discussion is that, first of all, we need to decide which behavior is
"correct":
>>> [].append == [].append
True or False?
(See the issue tracker for why the answer should probably be False.)
The general question is: if x.foo and y.foo resolve to the same method,
should "x.foo == y.foo" delegate to "x == y" or be based on "x is y"?
The behavior about this has always been purely accidental, with three
different results for user-defined methods versus built-in methods
versus method wrappers (those who know what the latter are, raise your
hand).
(Yes, Python < 2.5 managed three different behaviors instead of just
two: one of the types (don't ask me which) would base its equality on
the identity of the 'self', but still compute its hash from the hash of
'self'...)
A bientot,
Armin
More information about the Python-Dev
mailing list