Home

Gabriel Genellina wrote:
> En Thu, 20 Sep 2007 08:46:29 -0300, Steven D'Aprano
>
>> Another way is to use this class:
>>
>> class HashableList(list):
>> def __hash__(self):
>> return hash(tuple(self))
>
> ...and that will stop working as soon as the list is mutated (which is
> exactly what you said before)

Yup. I had suggested that technique in this thread, but it
doesn't really work. It hashes by state and compares by
state, but the actual key that a dict would store is the
object's identity. If the state has changed by the time
of a dict lookup, the dict will look in the hash-bucket
of the old state, but the object's equality test will
compare against the current state.
Bummer. Sorry.


--
--Bryan

previous
next

Re: SciPy's site is down
Re: super() doesn't get superclass
Re: Running daemon with zdaemon ... example help?
Re: Will Python 3.0 remove the global interpreter lock (GIL)
Re: Pythonic way for missing dict keys
Mimo Wszystko
Fundacja Avalon
Fundacja Hobbit
Fundacja Sloneczko
Kidprotect