pythonwrench.pickle module

pythonwrench.pickle.dump_pickle(data: Any, file: str | Path | PathLike | BinaryIO | None = None, /, *, overwrite: bool = True, make_parents: bool = True, to_builtins: bool = False, **pkl_dumps_kwds) bytes[source]

Dump content to PICKLE format into bytes and/or file.

Args:

data: Data to dump to PICKLE. file: Optional filepath to save dumped data. Not used if None. defaults to None. overwrite: If True, overwrite target filepath. defaults to True. make_parents: Build intermediate directories to filepath. defaults to True. to_builtins: If True, converts data to builtin equivalent before saving. defaults to False. **pkl_dumps_kwds: Other args passed to pickle.dumps.

Returns:

Dumped content as bytes.

pythonwrench.pickle.dumps_pickle(data: Any, /, *, to_builtins: bool = False, **pkl_dumps_kwds) bytes[source]

Dump content to PICKLE format into bytes.

Args:

data: Data to dump to PICKLE. to_builtins: If True, converts data to builtin equivalent before saving. defaults to False. **pkl_dumps_kwds: Other args passed to pickle.dumps.

Returns:

Dumped content as bytes.

pythonwrench.pickle.load_pickle(file: str | Path | BinaryIO, /, **pkl_loads_kwds) Any[source]

Load content from PICKLE file.

Args:

file: Filepath file path. **pkl_loads_kwds: Other args passed to pickle.loads.

pythonwrench.pickle.loads_pickle(content: bytes, /, **pkl_loads_kwds) Any[source]

Load content from raw bytes.

Args:

content: Encoded elements bytes. **pkl_loads_kwds: Other args passed to pickle.loads.

pythonwrench.pickle.read_pickle(file: str | Path | BinaryIO, /, **pkl_loads_kwds) Any[source]

Load content from PICKLE file.

Args:

file: Filepath file path. **pkl_loads_kwds: Other args passed to pickle.loads.

pythonwrench.pickle.save_pickle(data: Any, file: str | Path | PathLike | BinaryIO, /, *, overwrite: bool = True, make_parents: bool = True, to_builtins: bool = False, **pkl_dumps_kwds) None[source]

Dump content to PICKLE format into file.

Args:

data: Data to dump to PICKLE. file: Filepath to save dumped data. overwrite: If True, overwrite target filepath. defaults to True. make_parents: Build intermediate directories to filepath. defaults to True. to_builtins: If True, converts data to builtin equivalent before saving. defaults to False. **pkl_dumps_kwds: Other args passed to pickle.dumps.