Jeroen Demeyer <j.deme...@ugent.be> added the comment:
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 h = INITIAL_VALUE 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34751> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com