summaryrefslogtreecommitdiffstats
path: root/Doc/library/pickle.rst
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-01-21 01:39:54 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-01-21 01:39:54 (GMT)
commitb6457249bf38ff6f33415b5585e925aad5a1cfde (patch)
tree6fd47719ad041822127203b9789b06bb9e90ded8 /Doc/library/pickle.rst
parent240cae7d1732029fc4015262a7ef9f154ebcc7b2 (diff)
downloadcpython-b6457249bf38ff6f33415b5585e925aad5a1cfde.zip
cpython-b6457249bf38ff6f33415b5585e925aad5a1cfde.tar.gz
cpython-b6457249bf38ff6f33415b5585e925aad5a1cfde.tar.bz2
Fix the description of pickle protocol numbers
Diffstat (limited to 'Doc/library/pickle.rst')
-rw-r--r--Doc/library/pickle.rst39
1 files changed, 13 insertions, 26 deletions
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index 8976211..ce5467f 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -116,7 +116,9 @@ The module :mod:`pickletools` contains tools for analyzing data streams
generated by :mod:`pickle`. :mod:`pickletools` source code has extensive
comments about opcodes used by pickle protocols.
-There are currently 4 different protocols which can be used for pickling.
+There are currently 5 different protocols which can be used for pickling.
+The higher the protocol used, the more recent the version of Python needed
+to read the pickle produced.
* Protocol version 0 is the original "human-readable" protocol and is
backwards compatible with earlier versions of Python.
@@ -184,13 +186,10 @@ process more convenient:
Write a pickled representation of *obj* to the open :term:`file object` *file*.
This is equivalent to ``Pickler(file, protocol).dump(obj)``.
- The optional *protocol* argument tells the pickler to use the given
- protocol; supported protocols are 0, 1, 2, 3. The default protocol is 3; a
- backward-incompatible protocol designed for Python 3.
-
- Specifying a negative protocol version selects the highest protocol version
- supported. The higher the protocol used, the more recent the version of
- Python needed to read the pickle produced.
+ The optional *protocol* argument, an integer, tells the pickler to use
+ the given protocol; supported protocols are 0 to :data:`HIGHEST_PROTOCOL`.
+ If not specified, the default is :data:`DEFAULT_PROTOCOL`. If a negative
+ number is specified, :data:`HIGHEST_PROTOCOL` is selected.
The *file* argument must have a write() method that accepts a single bytes
argument. It can thus be an on-disk file opened for binary writing, a
@@ -206,17 +205,8 @@ process more convenient:
Return the pickled representation of the object as a :class:`bytes` object,
instead of writing it to a file.
- The optional *protocol* argument tells the pickler to use the given
- protocol; supported protocols are 0, 1, 2, 3 and 4. The default protocol
- is 3; a backward-incompatible protocol designed for Python 3.
-
- Specifying a negative protocol version selects the highest protocol version
- supported. The higher the protocol used, the more recent the version of
- Python needed to read the pickle produced.
-
- If *fix_imports* is true and *protocol* is less than 3, pickle will try to
- map the new Python 3 names to the old module names used in Python 2, so
- that the pickle data stream is readable with Python 2.
+ Arguments *protocol* and *fix_imports* have the same meaning as in
+ :func:`dump`.
.. function:: load(file, \*, fix_imports=True, encoding="ASCII", errors="strict")
@@ -292,13 +282,10 @@ The :mod:`pickle` module exports two classes, :class:`Pickler` and
This takes a binary file for writing a pickle data stream.
- The optional *protocol* argument tells the pickler to use the given
- protocol; supported protocols are 0, 1, 2, 3 and 4. The default protocol
- is 3; a backward-incompatible protocol designed for Python 3.
-
- Specifying a negative protocol version selects the highest protocol version
- supported. The higher the protocol used, the more recent the version of
- Python needed to read the pickle produced.
+ The optional *protocol* argument, an integer, tells the pickler to use
+ the given protocol; supported protocols are 0 to :data:`HIGHEST_PROTOCOL`.
+ If not specified, the default is :data:`DEFAULT_PROTOCOL`. If a negative
+ number is specified, :data:`HIGHEST_PROTOCOL` is selected.
The *file* argument must have a write() method that accepts a single bytes
argument. It can thus be an on-disk file opened for binary writing, a