frozendict

Chris Angelico rosuav at gmail.com
Fri Feb 10 11:08:04 CET 2012


On Fri, Feb 10, 2012 at 1:30 PM, Nathan Rice
<nathan.alexander.rice at gmail.com> wrote:
> The only thing needed to avoid the hash collision is that your hash
> function is not not 100% predictable just by looking at the python
> source code.  I don't see why every dict would have to be created
> differently.  I would think having the most ubiquitous data structure
> in your language be more predictable would be a priority.  Oh well....

It's perfectly predictable. If you put a series of keys into it, you
get those same keys back. Nobody ever promised anything about order.

If your hash function is not 100% predictable, that means it varies on
the basis of something that isn't part of either the Python
interpreter or the script being run. That means that, from one
execution to another of the exact same code, the results could be
different. The keys will come out in different orders.

ChrisA



More information about the Python-list mailing list