Python 3
    Python 3 - Overview
    Python 3 - Install
    Python 3 - REPL
    Python 3 - RegEx
    Python 3 - List
    Python 3 - XML/YAML
    Python 3 - DateTime
    Python 3 - Subprocess
    Python 3 - pickle
    Python 3 - env
    Python 3 - lib
    Python 3 - Trouble Shooting
    Python 2 to 3

Python 3 - Pickle

Updated: 2022-04-04
  • Pickling is the process whereby a Python object hierarchy is converted into a byte stream.
  • Unpickling is the inverse operation, whereby a byte stream (from a binary file or bytes-like object) is converted back into an object hierarchy.

The marshal serialization format is not guaranteed to be portable across Python versions. Because its primary job in life is to support .pyc files,

Pickle is Python Specific

The data format used by pickle is Python-specific.

  • Pros: there are no restrictions imposed by external standards
  • Cons: it means that non-Python programs may not be able to reconstruct pickled Python objects.

Pickle vs JSON

  • JSON is a text serialization format, while pickle is a binary serialization format;
  • JSON is human-readable, while pickle is not;
  • JSON is interoperable and widely used outside of the Python ecosystem, while pickle is Python-specific;
  • JSON, by default, can only represent a subset of the Python built-in types, and no custom classes; pickle can represent an extremely large number of Python types.