Last active
September 26, 2018 16:33
-
-
Save WillKoehrsen/90fa42e49648624b36fbedd5eb36a27a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import hashlib | |
N_PARTITIONS = 1000 | |
def id_to_hash(customer_id): | |
"""Return a 16-bit integer hash of a customer id string""" | |
customer_hash = int(hashlib.md5(customer_id).hexdigest(), 16) | |
partition = customer_hash % N_PARTITIONS | |
return partition |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment