This module contains methods for object serialization.
Instead of importing serialization functions from Python’s
pickle module directly, you should use the
loads functions defined here. In particular, these
methods will use
dumps_function to serialize
function objects which cannot be pickled by Python’s standard
methods. Note, however, pickling such methods should be avoided
since the implementation of
dumps_function uses non-portable
implementation details of CPython to achieve its goals.
- class pymor.core.pickle.Module(mod)¶
- pymor.core.pickle.dump(obj, file, protocol=None)¶
Tries hard to pickle a function object:
The function’s code object is serialized using the
For all global names used in the function’s code object the corresponding object in the function’s global namespace is pickled. In case this object is a module, the modules __package__ name is pickled.
All default arguments are pickled.
All objects in the function’s closure are pickled.
Note that also this is heavily implementation specific and will probably only work with CPython. If possible, avoid using this method.
Class decorator to mark a class as unpicklable.