from direct.stdpy.pickle import Pickler, Unpickler, dump, dumps, load, loads
This module extends standard Python’s pickle module so that it is capable of writing more efficient pickle files that contain Panda objects with shared pointers. In particular, a single Python structure that contains many NodePaths into the same scene graph will write the NodePaths correctly when used with this pickle module, so that when it is unpickled later, the NodePaths will still reference into the same scene graph together.
If you use the standard pickle module instead, the NodePaths will each duplicate its own copy of its scene graph.
This is necessary because the standard pickle module doesn’t provide a
mechanism for sharing context between different objects written to the
same pickle stream, so each NodePath has to write itself without
knowing about the other NodePaths that will also be writing to the
same stream. This replacement module solves this problem by defining
__reduce_persist__() replacement method for
which accepts a pointer to the Pickler object itself, allowing for
shared context between all objects written by that Pickler.
Unfortunately, cPickle cannot be supported, because it does not support extensions of this nature.
__init__(self, *args, **kw)¶
dump(obj, file, protocol=None)¶