Created
May 15, 2016 11:21
-
-
Save roylee0704/4a9775fc627fe739c1a4ec2d9c19d6bb to your computer and use it in GitHub Desktop.
python prehash implementation of tuple type. (simplified version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hash(tuple): | |
mult = 1000003 | |
x = 0x345678 | |
for index, item in enumerate(tuple): | |
x = ((x ^ hash(item)) * mult) & (1<<32) | |
mult += (82520 + (len(tuple)-index)*2) | |
return x + 97531 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you know where the numbers come from? For example, why is
97531
added? Why not 97530 or 97529? Why not13933
?