Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def serialize(data):
code = cloudpickle.dumps(data)
return base64.b64encode(code).decode("utf-8")
def dumps_fn(fn: Callable) -> bytes:
fn_hash = _get_fn_hash(fn)
try:
fn_bytes = _fn_dump_cache[fn_hash]
except KeyError:
fn_bytes = cloudpickle.dumps(fn)
_fn_dump_cache[fn_hash] = fn_bytes
return fn_bytes