pymor.core.pickle
¶
This module contains methods for object serialization.
Instead of importing serialization functions from Python’s
pickle
module directly, you should use the dump
, dumps
,
load
, 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.
Module Contents¶
- pymor.core.pickle.dumps_function(function)[source]¶
Tries hard to pickle a function object:
The function’s code object is serialized using the
marshal
module.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.
- pymor.core.pickle.loads_function(s)[source]¶
Restores a function serialized with
dumps_function
.