Slow comparison between two lists
Hrvoje Niksic
hniksic at xemacs.org
Thu Oct 23 09:25:02 EDT 2008
bearophileHUGS at lycos.com writes:
>> internal = set(list_internal)
> ...
>
> To do that the original poster may have to define a __hash__ and
> __eq__ methods in his/her class.
You're right. The OP states he implements __eq__, so he also needs a
matching __hash__, such as:
def __hash__(self, other):
return (hash(self.xcoord) ^ hash(self.ycoord) ^
hash(self.streetname) ^ hash(self.streetno))
More information about the Python-list
mailing list