[ python-Bugs-1617161 ] Instance methods compare equal when their self's are equal

SourceForge.net noreply at sourceforge.net
Sun Dec 17 13:19:51 CET 2006


Bugs item #1617161, was opened at 2006-12-16 21:36
Message generated for change (Comment added) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1617161&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Frank Niessink (fniessink)
Assigned to: Armin Rigo (arigo)
>Summary: Instance methods compare equal when their self's are equal

Initial Comment:
Python 2.5 was changed so that instance methods compare equal when their im_self attributes compare equal. Here's a link to that change: http://svn.python.org/view?rev=46739&view=rev

This is a problem if we want to distinguish between methods of instances that compare equal, for example when methods can be registered as callbacks (see attached example).

It seems unlogical to me that whether or not the instance methods of two different instances are equal or not depends on the equality of the instance.

Thanks, Frank

----------------------------------------------------------------------

>Comment By: Armin Rigo (arigo)
Date: 2006-12-17 12:19

Message:
Logged In: YES 
user_id=4771
Originator: NO

I see.  Indeed, in the callback situation the 2.5 change
is not very good.  On the other hand, I have a (possibly
more obscure) case where the new equality makes more
sense.  Note also that the change was meant to unify
the behavior of built-in and user method objects; e.g.
if you use callbacks as dict keys, then already in
previous Python versions it was impossible to use say
'mylist.append' as a callback.  Moreover, the hash of
user methods was strangely based on the hash of the
object itself already, which made dict key collisions
likely.

All in all I think that this part was an accident
and never designed; I won't pronounce myself and
suggest that python-dev should decide which of the
two behaviors is realy "expected".

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2006-12-16 23:07

Message:
Logged In: YES 
user_id=21627
Originator: NO

Armin, can you please comment?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1617161&group_id=5470


More information about the Python-bugs-list mailing list