gh-149807: Fix hash(frozendict): compute (key, value) pair hash#149841
gh-149807: Fix hash(frozendict): compute (key, value) pair hash#149841vstinner wants to merge 3 commits into
Conversation
|
It's good to avoid the frozenset hash code. It's not a good hash function. You can check this by constructing subsets of This showed up when trying to construct "bad cases" for the xxHash-based tuple hashing. Raymond was made aware of it, but never got around to "doing something" about it. No idea how the Boost-inspired scheme would work. Its scrambler does do some high-to-low propagation (via right shifts), but xxHash's rotate is best-of-all (and we took care to ensure that all major compilers did emit a "rotate" instruction instead of the longer-winded portable C spelling we use). Long story short: properly validating a compound hash function in the context of how it plays with CPython's hash results for primitive types (which, apart from string hashes, make no attempt at creating "random-looking" results) can require weeks of work. I can't make time for that, and have less than no interest in doing it again anyway ;-) I do have confidence in the tuple hashing approach - which was hard won. |
|
what about changing the starting hash to avoid the collision with |
frozendict_hashdoesnt match the PEP and might have too many collisions #149807