MCPcopy Create free account
hub / github.com/cxapython/catvm / json_based_hash

Function json_based_hash

selenium/scrapy_splash/utils.py:74–84  ·  view source on GitHub ↗

Return a hash for any JSON-serializable value. >>> json_based_hash({"foo": "bar", "baz": [1, 2]}) '0570066939bea46c610bfdc35b20f37ef09d05ed'

(value)

Source from the content-addressed store, hash-verified

72
73_hash_cache = {} # fast hash => hash
74def json_based_hash(value):
75 """
76 Return a hash for any JSON-serializable value.
77
78 >>> json_based_hash({"foo": "bar", "baz": [1, 2]})
79 '0570066939bea46c610bfdc35b20f37ef09d05ed'
80 """
81 fp = _fast_hash(value)
82 if fp not in _hash_cache:
83 _hash_cache[fp] = _json_based_hash(_process(value, sha=True))
84 return _hash_cache[fp]
85
86
87def _json_based_hash(value):

Callers 1

_process_requestMethod · 0.90

Calls 3

_fast_hashFunction · 0.85
_json_based_hashFunction · 0.85
_processFunction · 0.85

Tested by

no test coverage detected