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 a __reduce_persist__() replacement method for __reduce__(), 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.

Inheritance diagram

Inheritance diagram of direct.stdpy.pickle

class Pickler(*args, **kw)[source]

Bases: pickle._Pickler

__init__(self, *args, **kw)[source]
save(self, obj, save_persistent_id=True)[source]
class Unpickler(*args, **kw)[source]

Bases: pickle._Unpickler

__init__(self, *args, **kw)[source]
dump(obj, file, protocol=None)[source]
dumps(obj, protocol=None)[source]