Skip to content
Snippets Groups Projects
Commit 73f6dd49 authored by Daniel Silverstone's avatar Daniel Silverstone
Browse files

_cachekey.py: Add a variant of the calculator which take pre-sanitized input


In order to support a case where the caller already has pre-sanitized input
this variant of the cache key generator needs to exist.

Signed-off-by: default avatarDaniel Silverstone <daniel.silverstone@codethink.co.uk>
parent 7cd0d762
No related branches found
No related tags found
1 merge request!933WIP: Some more microoptimisations
......@@ -40,3 +40,20 @@ def generate_key(value):
ordered = _yaml.node_sanitize(value)
string = pickle.dumps(ordered)
return hashlib.sha256(string).hexdigest()
# generate_key_pre_sanitized()
#
# Generate an sha256 hex digest from the given value. The value
# must be (a) compatible with generate_key() and (b) already have
# been passed through _yaml.node_sanitize()
#
# Args:
# value: A sanitized value to get a key for
#
# Returns:
# (str): An sha256 hex digest of the given value
#
def generate_key_pre_sanitized(value):
string = pickle.dumps(value)
return hashlib.sha256(string).hexdigest()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment