Skip to content

Instantly share code, notes, and snippets.

@roylee0704
Created May 15, 2016 11:22
Show Gist options
  • Save roylee0704/27200a9cf547b877bbbfe03ae76af88d to your computer and use it in GitHub Desktop.
Save roylee0704/27200a9cf547b877bbbfe03ae76af88d to your computer and use it in GitHub Desktop.
Python hash implementation of type str.
def hash(string):
x = string[0] << 7
for chr in string[1:]:
x = ((1000003 * x) ^ chr) & (1<<32)
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment