mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.)
This commit is contained in:
parent
bce036b49e
commit
57c2d930f6
2 changed files with 2 additions and 0 deletions
|
@ -280,6 +280,7 @@ tuplehash(PyTupleObject *v)
|
|||
x = (x ^ y) * mult;
|
||||
mult += 82520L + len + len;
|
||||
}
|
||||
x += 97531L;
|
||||
if (x == -1)
|
||||
x = -2;
|
||||
return x;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue