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)
| 1527 | |
| 1528 | |
| 1529 | def dumps(obj, protocol=None, buffer_callback=None): |
| 1530 | """Serialize obj as a string of bytes allocated in memory |
| 1531 | |
| 1532 | protocol defaults to cloudpickle.DEFAULT_PROTOCOL which is an alias to |
| 1533 | pickle.HIGHEST_PROTOCOL. This setting favors maximum communication |
| 1534 | speed between processes running the same Python version. |
| 1535 | |
| 1536 | Set protocol=pickle.DEFAULT_PROTOCOL instead if you need to ensure |
| 1537 | compatibility with older versions of Python (although this is not always |
| 1538 | guaranteed to work because cloudpickle relies on some internal |
| 1539 | implementation details that can change from one Python version to the |
| 1540 | next). |
| 1541 | """ |
| 1542 | with io.BytesIO() as file: |
| 1543 | cp = Pickler(file, protocol=protocol, buffer_callback=buffer_callback) |
| 1544 | cp.dump(obj) |
| 1545 | return file.getvalue() |
| 1546 | |
| 1547 | |
| 1548 | # Include pickles unloading functions in this namespace for convenience. |
searching dependent graphs…