Add a final permutation step to the tuple hash function.

Prevents a collision pattern that occurs with nested tuples.
(Yitz Gale provided code that repeatably demonstrated the weakness.)
This commit is contained in:
Raymond Hettinger 2004-06-10 18:42:15 +00:00
parent bce036b49e
commit 57c2d930f6
2 changed files with 2 additions and 0 deletions

View File

@ -190,6 +190,7 @@ Gyro Funch
Peter Funk
Geoff Furnish
Lele Gaifax
Yitzchak Gale
Raymund Galvin
Nitin Ganatra
Fred Gansevles

View File

@ -280,6 +280,7 @@ tuplehash(PyTupleObject *v)
x = (x ^ y) * mult;
mult += 82520L + len + len;
}
x += 97531L;
if (x == -1)
x = -2;
return x;