Skip to content

Commit ee0692a

Browse files
committed
gh-118830: Bump DEFAULT_PROTOCOL to 5 (#118830)
1 parent e9875ec commit ee0692a

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

Doc/library/pickle.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ The :mod:`pickle` module provides the following constants:
199199

200200
An integer, the default :ref:`protocol version <pickle-protocols>` used
201201
for pickling. May be less than :data:`HIGHEST_PROTOCOL`. Currently the
202-
default protocol is 4, first introduced in Python 3.4 and incompatible
202+
default protocol is 5, first introduced in Python 3.4 and incompatible
203203
with previous versions.
204204

205205
.. versionchanged:: 3.0
@@ -210,6 +210,10 @@ The :mod:`pickle` module provides the following constants:
210210

211211
The default protocol is 4.
212212

213+
.. versionchanged:: 3.14
214+
215+
The default protocol is 5.
216+
213217
The :mod:`pickle` module provides the following functions to make the pickling
214218
process more convenient:
215219

Doc/whatsnew/3.14.rst

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Added :func:`ast.compare` for comparing two ASTs.
9797
Optimizations
9898
=============
9999

100+
* The default protocol in the :mod:`pickle` module is now Protocol 5.
100101

101102

102103

Lib/pickle.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
bytes_types = (bytes, bytearray)
5252

5353
# These are purely informational; no code uses these.
54-
format_version = "4.0" # File format version we write
54+
format_version = "5.0" # File format version we write
5555
compatible_formats = ["1.0", # Original protocol 0
5656
"1.1", # Protocol 0 with INST added
5757
"1.2", # Original protocol 1
@@ -68,7 +68,7 @@
6868
# The protocol we write by default. May be less than HIGHEST_PROTOCOL.
6969
# Only bump this if the oldest still supported version of Python already
7070
# includes it.
71-
DEFAULT_PROTOCOL = 4
71+
DEFAULT_PROTOCOL = 5
7272

7373
class PickleError(Exception):
7474
"""A common base class for the other pickling exceptions."""
@@ -408,7 +408,7 @@ def __init__(self, file, protocol=None, *, fix_imports=True,
408408
409409
The optional *protocol* argument tells the pickler to use the
410410
given protocol; supported protocols are 0, 1, 2, 3, 4 and 5.
411-
The default protocol is 4. It was introduced in Python 3.4, and
411+
The default protocol is 5. It was introduced in Python 3.4, and
412412
is incompatible with previous versions.
413413
414414
Specifying a negative protocol version selects the highest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump :mod:`pickle` default protocol to ``5``.

Modules/_pickle.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -4693,7 +4693,7 @@ This takes a binary file for writing a pickle data stream.
46934693
46944694
The optional *protocol* argument tells the pickler to use the given
46954695
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
4696-
protocol is 4. It was introduced in Python 3.4, and is incompatible
4696+
protocol is 5. It was introduced in Python 3.4, and is incompatible
46974697
with previous versions.
46984698
46994699
Specifying a negative protocol version selects the highest protocol
@@ -7504,7 +7504,7 @@ be more efficient.
75047504
75057505
The optional *protocol* argument tells the pickler to use the given
75067506
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
7507-
protocol is 4. It was introduced in Python 3.4, and is incompatible
7507+
protocol is 5. It was introduced in Python 3.4, and is incompatible
75087508
with previous versions.
75097509
75107510
Specifying a negative protocol version selects the highest protocol
@@ -7575,7 +7575,7 @@ Return the pickled representation of the object as a bytes object.
75757575
75767576
The optional *protocol* argument tells the pickler to use the given
75777577
protocol; supported protocols are 0, 1, 2, 3, 4 and 5. The default
7578-
protocol is 4. It was introduced in Python 3.4, and is incompatible
7578+
protocol is 5. It was introduced in Python 3.4, and is incompatible
75797579
with previous versions.
75807580
75817581
Specifying a negative protocol version selects the highest protocol

0 commit comments

Comments
 (0)