By default, the pickle data format uses a printable ASCII representation.
This is slightly more voluminous than a binary representation. The big
advantage of using printable ASCII (and of some other characteristics of
pickle‘s representation) is that for debugging or recovery purposes it is
possible for a human to read the pickled file with a standard text editor.

There are currently 3 different protocols which can be used for pickling.

  • Protocol version 0 is the original ASCII protocol and is backwards compatible
    with earlier versions of Python.
  • Protocol version 1 is the old binary format which is also compatible with
    earlier versions of Python.
  • Protocol version 2 was introduced in Python 2.3. It provides much more
    efficient pickling of new-style classes.

Refer to PEP 307 for more information.

If a protocol is not specified, protocol 0 is used. If protocol is specified
as a negative value or HIGHEST_PROTOCOL, the highest protocol version
available will be used.

Changed in version 2.3: Introduced the protocol parameter.

A binary format, which is slightly more efficient, can be chosen by specifying a
protocol version >= 1.

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。