[Python-Dev] Equality on method objects
Nick Coghlan
ncoghlan at gmail.com
Sun Mar 9 23:42:05 CET 2008
Guido van Rossum wrote:
> That said, if there's a use case, I agree that it would be okay with
> basing the equality of x.foo and y.foo on whether x and y are the same
> object, not on whether x==y (consider 0 .__add__ == 0.0 .__add__).
The use case in the issue tracker was maintaining a collection of unique
callbacks, some of which could be bound methods - the current behaviour
is actively harmful to that use case, since some of the later callbacks
may fail to register properly (due to their self comparing equal to
another instance of the same type that already had its callback method
in the list).
That same use case is what makes it useful to consider the same method
on a single object to be equal - there is little point in having a bound
method like "x.notify" in a callback list twice.
So for myself, +1 on acknowledging issue 1617161 as a bug and fixing it
as Armin suggests.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-Dev
mailing list