[Python-Dev] Counting collisions for the win

Lennart Regebro regebro at gmail.com
Sun Jan 22 20:53:41 CET 2012


On Sun, Jan 22, 2012 at 11:11, Victor Stinner
<victor.stinner at haypocalc.com> wrote:
>> This seed is chosen randomly at runtime, but cannot
>> change once chosen.
>
> The hash is used to compare objects: if hash(obj1) != hash(obj2),
> objects are considered different. So two strings must have the same
> hash if their value is the same.
>
>> Salt could also be an appropriate term here, but since salt is
>> generally changed on a per-use basis (a single process may use many
>> different salts), seed is more correct, since this value is only
>> chosen once per process.
>
> We may use a different salt per dictionary.

Can we do that? I was thinking of ways to not raise errors when we get
over a collision count, but instead somehow change the way the
dictionary behaves when we get over the collision count, but I
couldn't come up with something. Somehow adding a salt would be one
possibility. But I don't see how it's doable except for the
string-keys only case mentioned before.

But I might just be lacking imagination. :-)

//Lennart


More information about the Python-Dev mailing list