frozendict (v0.1)

Steven D'Aprano steve at
Fri Oct 8 02:31:56 CEST 2010

On Fri, 08 Oct 2010 00:23:30 +0000, kj wrote:

> In <87hbgxlk67.fsf at> Arnaud Delobelle <arnodel at>
> writes:
>>A simple fix is to use hash(frozenset(self.items())) instead.
> Thanks for pointing out the hash bug.  It was an oversight: I meant to
> write
>     def __hash__(self):
>         return hash(sorted(tuple(self.items())))
> I imagine that frozenset is better than sorted(tuple(...)) here, but
> it's not obvious to me why.

Because it's always better to use a well-written, fast, efficient, 
correct, well-tested wheel than to invent your own slow, incorrect 
wheel :)


More information about the Python-list mailing list