From: Raymond Hettinger Date: Thu, 10 Jun 2004 18:42:15 +0000 (+0000) Subject: Add a final permutation step to the tuple hash function. X-Git-Tag: v2.4a1~212 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=57c2d930f688ca50248241919bd815c85bf39939;p=python 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.) --- diff --git a/Misc/ACKS b/Misc/ACKS index 6d3ad2cb83..480a1ec1eb 100644 --- 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 diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index ff20b43eeb..ea7d753022 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -280,6 +280,7 @@ tuplehash(PyTupleObject *v) x = (x ^ y) * mult; mult += 82520L + len + len; } + x += 97531L; if (x == -1) x = -2; return x;