diff options
author | Łukasz Langa <lukasz@langa.pl> | 2018-04-03 23:06:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-03 23:06:53 -0700 |
commit | c51d8c9ba6211d77db639487501f89aa9b4bcbb1 (patch) | |
tree | cabc297cea85143550c1755cbd9a19ec9c2c2603 /Doc | |
parent | bpo-33195: Doc: Deprecate Py_UNICODE in c-api/arg (GH-6329) (diff) | |
download | cpython-c51d8c9ba6211d77db639487501f89aa9b4bcbb1.tar.gz cpython-c51d8c9ba6211d77db639487501f89aa9b4bcbb1.tar.bz2 cpython-c51d8c9ba6211d77db639487501f89aa9b4bcbb1.zip |
bpo-23403: Bump pickle.DEFAULT_PROTOCOL to 4 (#6355)
This makes performance better and produces shorter pickles. This change is backwards compatible up to the oldest currently supported version of Python (3.4).
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/pickle.rst | 20 | ||||
-rw-r--r-- | Doc/whatsnew/3.8.rst | 3 |
2 files changed, 17 insertions, 6 deletions
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst index d0c4cf937c8..ea854fae194 100644 --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -135,14 +135,14 @@ to read the pickle produced. information about improvements brought by protocol 2. * Protocol version 3 was added in Python 3.0. It has explicit support for - :class:`bytes` objects and cannot be unpickled by Python 2.x. This is - the default protocol, and the recommended protocol when compatibility with - other Python 3 versions is required. + :class:`bytes` objects and cannot be unpickled by Python 2.x. This was + the default protocol in Python 3.0--3.7. * Protocol version 4 was added in Python 3.4. It adds support for very large objects, pickling more kinds of objects, and some data format - optimizations. Refer to :pep:`3154` for information about improvements - brought by protocol 4. + optimizations. It is the default protocol starting with Python 3.8. + Refer to :pep:`3154` for information about improvements brought by + protocol 4. .. note:: Serialization is a more primitive notion than persistence; although @@ -179,8 +179,16 @@ The :mod:`pickle` module provides the following constants: An integer, the default :ref:`protocol version <pickle-protocols>` used for pickling. May be less than :data:`HIGHEST_PROTOCOL`. Currently the - default protocol is 3, a new protocol designed for Python 3. + default protocol is 4, first introduced in Python 3.4 and incompatible + with previous versions. + .. versionchanged:: 3.0 + + The default protocol is 3. + + .. versionchanged:: 3.8 + + The default protocol is 4. The :mod:`pickle` module provides the following functions to make the pickling process more convenient: diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 4e6c8517375..2f42a9f8ba7 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -94,6 +94,9 @@ Improved Modules Optimizations ============= +* The default protocol in the :mod:`pickle` module is now Protocol 4, + first introduced in Python 3.4. It offers better performance and smaller + size compared to Protocol 3 available since Python 3.0. Build and C API Changes ======================= |