On Sun, Mar 9, 2008 at 9:02 AM, Armin Rigo <[EMAIL PROTECTED]> wrote:
> 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'...)

They should only compare equal if interchangeable.  In the case of a
mutable container (ie list), a value comparison of self is irrelevant
garbage, so it should always be compared (and hashed) based on
identity.

IOW, "x = []; x.append == x.append" should be True, and everything
else should be False.

-- 
Adam Olsen, aka Rhamphoryncus
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to