Tutorials‎ > ‎

Serialization

Serialization is the process of converting an object into a form that can be stored, often in a disk file, and reconstructed later as needed. It is a very handy technique especially for complicated objects, such as simulation systems, which can be difficult to recreate from scratch.

In pDynamo, the principal way of serializing and deserializing an object is to use the Pickle and Unpickle functions that employ Python's pickle protocol. It is also possible to serialize in YAML format, with the YAMLPickle and YAMLUnpickle functions, when a more human-readable form of the serialized object is desired. It is for this reason that many of pDynamo's parameter files employ YAML serialization. Older versions of pDynamo also had a third form of serialization, based upon XML and the XMLPickle and XMLUnpickle functions, but this format is no longer available.

Although useful, serialization depends intimately on an object's internal structure. This means that in a rapidly-evolving program, such as pDynamo, objects serialized with an early version of the program may no longer be deserializable by later ones. Efforts are being made to move towards a version-independent serialization structure but, in the meantime, users are advised to preserve the scripts and protocols that they employed to generate particular objects and, where appropriate, backup data to files whose formats are unlikely to change.