Pickle

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Links)
Line 28: Line 28:
 
* [https://docs.python.org/2/library/pickle.html Python 2 Pickle library docs]
 
* [https://docs.python.org/2/library/pickle.html Python 2 Pickle library docs]
 
* [https://docs.python.org/3/library/pickle.html Python 3 Pickle library docs]
 
* [https://docs.python.org/3/library/pickle.html Python 3 Pickle library docs]
 +
* [http://legacy.python.org/dev/peps/pep-0307/ PEP 307: Extensions to the Pickle protocol (2.2)]
 +
* [http://legacy.python.org/dev/peps/pep-3154/ PEP 3154: Pickle protocol version 4]
 
* [[Wikipedia:Pickle (Python)|Wikipedia article]]
 
* [[Wikipedia:Pickle (Python)|Wikipedia article]]
 
* [http://stackoverflow.com/questions/8968884/python-serialization-why-pickle Why Pickle?]
 
* [http://stackoverflow.com/questions/8968884/python-serialization-why-pickle Why Pickle?]
 
* [http://python.about.com/od/pythonstandardlibrary/a/pickle_intro.htm Pickle intro]
 
* [http://python.about.com/od/pythonstandardlibrary/a/pickle_intro.htm Pickle intro]
 
* [https://blog.nelhage.com/2011/03/exploiting-pickle/ Exploiting Misuse of Python's "Pickle"]
 
* [https://blog.nelhage.com/2011/03/exploiting-pickle/ Exploiting Misuse of Python's "Pickle"]

Revision as of 21:46, 17 May 2014

File Format
Name Pickle
Ontology
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

Links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox