Created
September 26, 2020 22:08
-
-
Save yakkomajuri/622f80e143078ace6a45dceef9b88ebe to your computer and use it in GitHub Desktop.
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
# Property filtering logic omitted | |
# Rollout percentage logic: | |
__LONG_SCALE__ = float(0xFFFFFFFFFFFFFFF) | |
def _hash(self, key: str, distinct_id: str) -> float: | |
hash_key = "%s.%s" % (key, distinct_id) | |
hash_val = int(hashlib.sha1(hash_key.encode("utf-8")).hexdigest()[:15], 16) | |
return hash_val / __LONG_SCALE__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment