Why keep identity-based equality comparison?

Steven Bethard steven.bethard at gmail.com
Tue Jan 10 22:30:07 EST 2006


Mike Meyer wrote:
> spam.noam at gmail.com writes:
> 
>> My question is, what reasons are left for leaving the current default
>> equality operator for Py3K, not counting backwards-compatibility?
>> (assume that you have idset and iddict, so explicitness' cost is only
>> two characters, in Guido's example)
> 
> Yes. Searching for items in heterogenous containers. With your change
> in place, the "in" operator becomes pretty much worthless on
> containers of heterogenous objects. Ditto for container methods that
> do searches for "equal" members. Whenever you compare two objects that
> don't have the same type, you'll get an exception and terminate the
> search. If the object your searching for would have been found
> "later", you lose - you'll get the wrong answer.

Not to advocate one way or the other, but how often do you use 
heterogeneous containers?  I couldn't find any in my (admittedly small) 
codebase.  Could you post some examples of what kind of problems lend 
themselves to being solved by heterogeneous containers?

Thanks,

STeVe



More information about the Python-list mailing list