From Just Solve the File Format Problem
Jump to: navigation, search
File Format
Name Pickle
Extension(s) .pickle
I don't want a pickle; Just want to ride on my motorsickle.
-- Arlo Guthrie

Pickle is a serialization format used by the Python programming language. There have been several different protocols, introduced in different versions of Python. Newer Python versions support the earlier protocols, but data using them wouldn't be compatible with earlier Python versions not supporting that version of the protocol. Pickle is Python-specific, so data intended to be used across different programs in different programming languages would be better off using a more standardized format such as JSON (which is also supported by a standard Python library), but Pickle is optimized for Python, supporting greater speed and compactness and able to encode just about anything that can be stored in a Python variable, including the quirkier Python constructs which might not be easy to represent in other formats. By the same token, however, this makes Pickle a potentially dangerous format since it can encapsulate such things as functions which do harmful things, allowing it to become a medium for transmitting trojan horse programs. For this reason, it is not a good idea to use Pickle as a format for exchanging data from untrusted sources, or as input/output in public-facing APIs.

Pickle data may be saved to a file, a database, or a network; it does not necessarily have a distinctive file extension, but .pickle is sometimes used.

Pickle protocols

  • 0: Text-based format used in early Python versions
  • 1: Binary format used in early Python versions
  • 2: Introduced in Python 2.3; better support for new-style classes
  • 3: Introduced in Python 3.0; supports new Python 3.0 types
  • 4: Introduced in Python 3.4; some improvements to efficiency, and added support for more data types

Sample data


Personal tools