MCPcopy Create free account
hub / github.com/cloudpipe/cloudpickle / dumps

Function dumps

cloudpickle/cloudpickle.py:1543–1559  ·  view source on GitHub ↗

Serialize obj as a string of bytes allocated in memory protocol defaults to cloudpickle.DEFAULT_PROTOCOL which is an alias to pickle.HIGHEST_PROTOCOL. This setting favors maximum communication speed between processes running the same Python version. Set protocol=pickle.DEFAULT_PROT

(obj, protocol=None, buffer_callback=None)

Source from the content-addressed store, hash-verified

1541
1542
1543def dumps(obj, protocol=None, buffer_callback=None):
1544 """Serialize obj as a string of bytes allocated in memory
1545
1546 protocol defaults to cloudpickle.DEFAULT_PROTOCOL which is an alias to
1547 pickle.HIGHEST_PROTOCOL. This setting favors maximum communication
1548 speed between processes running the same Python version.
1549
1550 Set protocol=pickle.DEFAULT_PROTOCOL instead if you need to ensure
1551 compatibility with older versions of Python (although this is not always
1552 guaranteed to work because cloudpickle relies on some internal
1553 implementation details that can change from one Python version to the
1554 next).
1555 """
1556 with io.BytesIO() as file:
1557 cp = Pickler(file, protocol=protocol, buffer_callback=buffer_callback)
1558 cp.dump(obj)
1559 return file.getvalue()
1560
1561
1562# Include pickles unloading functions in this namespace for convenience.

Callers 4

subprocess_pickle_stringFunction · 0.90
pickle_echoFunction · 0.90
call_funcFunction · 0.90
runMethod · 0.90

Calls 2

dumpMethod · 0.95
PicklerClass · 0.85

Tested by 4

subprocess_pickle_stringFunction · 0.72
pickle_echoFunction · 0.72
call_funcFunction · 0.72
runMethod · 0.72