3.14 pickle -- Python object serialization
Keywords: lib

# 3.14 `pickle` -- Python object serialization

The `pickle` module implements a fundamental, but powerful algorithm for serializing and de-serializing a Python object structure. ``Pickling'' is the process whereby a Python object hierarchy is converted into a byte stream, and ``unpickling'' is the inverse operation, whereby a byte stream is converted back into an object hierarchy. Pickling (and unpickling) is alternatively known as ``serialization'', ``marshalling,''3.2 or ``flattening'', however the preferred term used here is ``pickling'' and ``unpickling'' to avoid confusing.

This documentation describes both the `pickle` module and the `cPickle` module.

#### Footnotes

... ``marshalling,''3.2
  Don't confuse this with the `marshal` module

Subsections

- 3.14.1 Relationship to other Python modules
- 3.14.2 Data stream format
- 3.14.3 Usage
- 3.14.4 What can be pickled and unpickled?
- 3.14.5 The pickle protocol
  - 3.14.5.1 Pickling and unpickling normal class instances
  - 3.14.5.2 Pickling and unpickling extension types
  - 3.14.5.3 Pickling and unpickling external objects
- 3.14.6 Security
- 3.14.7 Example