pickling module
Define a class to pickle objects.
“pickling” a file comes down to saving it in binary format. It can be loaded
and used again later, even with a different Python instance. This is useful
when you want to study a Fault that took a long time to be
compensated, or a SimulationOutput obtained by a time-consuming
TraceWin multiparticle simulation.
Warning
This a very basic pickling. Do not use for long-term storage, but for debug only.
Note
Some attributes such as lambda function in FieldMap or modules in
SimulationOutput cannot be pickled by the built-in pickle
module. I do not plan to refactor them, so for now we stick with
cloudpickle module.
Some objects have built-in pickle and unpickle methods, namely:
- class MyPickler
Bases:
ABCDefine an object that can save/load arbitrary objects to files.
- abstract pickle(my_object: object, path: Path | str) None
Pickle (“save”) the object to a binary file.
- abstract unpickle(path: Path | str) object
Unpickle (“load”) the given path to recreate original object.
- _abc_impl = <_abc._abc_data object at 0x7fd3ce6dd940>