pyrseus.core.pickle.OncePickledObject¶
- class pyrseus.core.pickle.OncePickledObject(obj, dumps, loads)[source]¶
Creates a wrapper around an arbitrary Python object that forces it to be pickled with the chosen pickler, but a copy of the original unwrapped object is returned at unpickling time.
This wrapper does not provide any proxying of attributes or methods. It is only intended to be used when users know the object will be pickled and unpickled exactly once before use.
>>> opo123 = OncePickledObject(123, pickle.dumps, pickle.loads) >>> opo123 <pyrseus.core.pickle.OncePickledObject object at ...> >>> pickle.loads(pickle.dumps(opo123, -1)) 123
Methods
__init__(obj, dumps, loads)