Frank Niessink wrote: > I tried to lookup the python source code where the actual comparison > happens. I think it is in methodobject.c (I'm not familiar with the > python source so please correct me if I'm wrong), meth_compare. That > function did not change between python 2.4.4 and 2.5. Moreover, the > implementation suggests that the only way for two methods to be equal is > that their instances point to the same object and their method > definitions are the same. Am I interpreting that correctly?
No, the comparison happens in function instancemethod_compare in file classobject.c: http://svn.python.org/view/python/trunk/Objects/classobject.c?view=markup This method was changed in Python 2.5. Previously, two instancemethods compared equal if their im_self attributes were *identical* and their im_func attributes were equal. Now, they compare equal if their im_self attributes are *equal* and their im_func attributes are equal. See this change: http://svn.python.org/view?rev=46739&view=rev A small example: >type cmpmethod.py class Test(object): def meth(self): pass def __eq__(self, other): return True >python24 Python 2.4.4 (#71, Oct 18 2006, 08:34:43) ... >>> from cmpmethod import Test >>> a, b = Test(), Test() >>> a.meth == b.meth False >>> ^Z >python25 Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) ... >>> from cmpmethod import Test >>> a, b = Test(), Test() >>> a.meth == b.meth True >>> ^Z If you think this is a bug, you should report it to the bugtracker: http://sourceforge.net/bugs/?group_id=5470 Ziga -- http://mail.python.org/mailman/listinfo/python-list