pickle and cPickle

The pickle and cPickle modules are used to serialize Python objects into a stream of bytes suitable for storing in a file, transferring across a network, or placing in a database. This process is variously called pickling, serializing, marshalling, or flattening. The resulting byte stream can also be converted back into a series of Python objects using an unpickling process.

The pickling and unpickling processes are controlled by using Pickler and Unpickler objects, as created by the following two functions:

Pickler(file [, protocol ])

Creates a pickling object that writes data to the file object file.protocol specifies the output format of the data. Protocol 0 (the default) is a text-based format that is backward compatible ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.