[Python-checkins] python/dist/src/Objects tupleobject.c,2.90,2.91
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Tue Jun 1 02:36:26 EDT 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4903/Objects
Modified Files:
tupleobject.c
Log Message:
SF bug #942952: Weakness in tuple hash
(Basic approach and test concept by Tim Peters.)
* Improved the hash to reduce collisions.
* Added the torture test to the test suite.
Index: tupleobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v
retrieving revision 2.90
retrieving revision 2.91
diff -C2 -d -r2.90 -r2.91
*** tupleobject.c 21 Mar 2004 22:29:05 -0000 2.90
--- tupleobject.c 1 Jun 2004 06:36:24 -0000 2.91
***************
*** 263,266 ****
--- 263,267 ----
register int len = v->ob_size;
register PyObject **p;
+ long mult = 1000003L;
x = 0x345678L;
p = v->ob_item;
***************
*** 269,275 ****
if (y == -1)
return -1;
! x = (1000003*x) ^ y;
}
- x ^= v->ob_size;
if (x == -1)
x = -2;
--- 270,276 ----
if (y == -1)
return -1;
! x = (x ^ y) * mult;
! mult += 69068L + len + len;
}
if (x == -1)
x = -2;
More information about the Python-checkins
mailing list