This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdemeyer
Recipients jdemeyer, ned.deily, rhettinger, tim.peters
Date 2018-09-21.06:10:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
To come back to the topic of hashing, with "Bernstein hash" for tuples I did indeed mean the simple (in Python pseudocode):

# t is a tuple
for x in t:
    z = hash(x)
    h = (h * MULTIPLIER) + z
return h

I actually started working on the code and there is indeed an issue with the hashes of (X, (Y, Z)) and (Y, (X, Z)) being equal that way. But that can be solved by replacing "hash(x)" in the loop by something slightly more complicated. After thinking about it, I decided to go for shifting higher to lower bits, so replacing z by z^(z >> 32) or something like that.

This also has the benefit of mixing the high-order bits into the low-order bits, which is an additional improvement over the current code.

Since I already wrote the code anyway, I'll create a PR for it.
Date User Action Args
2018-09-21 06:10:27jdemeyersetrecipients: + jdemeyer, tim.peters, rhettinger, ned.deily
2018-09-21 06:10:27jdemeyersetmessageid: <>
2018-09-21 06:10:27jdemeyerlinkissue34751 messages
2018-09-21 06:10:27jdemeyercreate