O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required