From 57c2d930f688ca50248241919bd815c85bf39939 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 10 Jun 2004 18:42:15 +0000 Subject: 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.) --- Misc/ACKS | 1 + Objects/tupleobject.c | 1 + 2 files changed, 2 insertions(+) diff --git a/Misc/ACKS b/Misc/ACKS index 6d3ad2c..480a1ec 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 ff20b43..ea7d753 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; -- cgit v0.12