bpo-26163: Frozenset hash improvement (GH-5194) (#5198)

(cherry picked from commit b44c5169f6)
This commit is contained in:
Miss Islington (bot) 2018-01-16 02:27:15 -08:00 committed by Raymond Hettinger
parent b92c159efa
commit e7dbd06583
2 changed files with 3 additions and 0 deletions

View file

@ -0,0 +1,2 @@
Improved frozenset() hash to create more distinct hash values when faced
with datasets containing many similar values.

View file

@ -790,6 +790,7 @@ frozenset_hash(PyObject *self)
hash ^= ((Py_uhash_t)PySet_GET_SIZE(self) + 1) * 1927868237UL;
/* Disperse patterns arising in nested frozensets */
hash ^= (hash >> 11) ^ (~hash >> 25);
hash = hash * 69069U + 907133923UL;
/* -1 is reserved as an error code */