Return a hash for any JSON-serializable value. >>> json_based_hash({"foo": "bar", "baz": [1, 2]}) '0570066939bea46c610bfdc35b20f37ef09d05ed'
(value)
| 72 | |
| 73 | _hash_cache = {} # fast hash => hash |
| 74 | def 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 | |
| 87 | def _json_based_hash(value): |
no test coverage detected