summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-06-04 06:35:20 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-06-04 06:35:20 (GMT)
commit4ec44e851dafc78c534efad127403d167feb4180 (patch)
tree2380e5f7da1889215340c97e3988fb2d94227276 /Objects/tupleobject.c
parent4e49b836db96264b3b5236794a3200eea32b2519 (diff)
downloadcpython-4ec44e851dafc78c534efad127403d167feb4180.zip
cpython-4ec44e851dafc78c534efad127403d167feb4180.tar.gz
cpython-4ec44e851dafc78c534efad127403d167feb4180.tar.bz2
Replaced arbitrary addend in tuple_hash with one that is known to generate
many more prime multipliers and that performs well on collision tests.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r--Objects/tupleobject.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 4cb80f0..ff20b43 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -256,6 +256,14 @@ Done:
return result;
}
+/* The addend 82520, was selected from the range(0, 1000000) for
+ generating the greatest number of prime multipliers for tuples
+ upto length eight:
+
+ 1082527, 1165049, 1082531, 1165057, 1247581, 1330103, 1082533,
+ 1330111, 1412633, 1165069, 1247599, 1495177, 1577699
+*/
+
static long
tuplehash(PyTupleObject *v)
{
@@ -270,7 +278,7 @@ tuplehash(PyTupleObject *v)
if (y == -1)
return -1;
x = (x ^ y) * mult;
- mult += 69068L + len + len;
+ mult += 82520L + len + len;
}
if (x == -1)
x = -2;