]> granicus.if.org Git - python/commitdiff
Add a final permutation step to the tuple hash function.
authorRaymond Hettinger <python@rcn.com>
Thu, 10 Jun 2004 18:42:15 +0000 (18:42 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 10 Jun 2004 18:42:15 +0000 (18:42 +0000)
Prevents a collision pattern that occurs with nested tuples.
(Yitz Gale provided code that repeatably demonstrated the weakness.)

Misc/ACKS
Objects/tupleobject.c

index 6d3ad2cb83fb2f4517d6f514d4a08aea03d90232..480a1ec1eb0cdf9a15917f30ee99968086dd726e 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -190,6 +190,7 @@ Gyro Funch
 Peter Funk
 Geoff Furnish
 Lele Gaifax
+Yitzchak Gale
 Raymund Galvin
 Nitin Ganatra
 Fred Gansevles
index ff20b43eeba47061233c750e00bc04b7686cb594..ea7d75302238d5e81eea50e781885bce8c462e6c 100644 (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;