Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita19e48a

Browse files
committed
gh-118830: Bump DEFAULT_PROTOCOL to 5 (#118830)
1 parent127c1d2 commita19e48a

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

‎Doc/library/pickle.rst‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,14 @@ to read the pickle produced.
156156

157157
* Protocol version 4 was added in Python 3.4. It adds support for very large
158158
objects, pickling more kinds of objects, and some data format
159-
optimizations.It is the default protocolstarting withPython 3.8.
159+
optimizations.This was the default protocolinPython 3.8--3.14.
160160
Refer to:pep:`3154` for information about improvements brought by
161161
protocol 4.
162162

163163
* Protocol version 5 was added in Python 3.8. It adds support for out-of-band
164-
data and speedup for in-band data. Refer to:pep:`574` for information about
165-
improvements brought by protocol 5.
164+
data and speedup for in-band data. It is the default protocol starting with
165+
Python 3.14. Refer to:pep:`574` for information about improvements brought
166+
by protocol 5.
166167

167168
..note::
168169
Serialization is a more primitive notion than persistence; although
@@ -199,8 +200,10 @@ The :mod:`pickle` module provides the following constants:
199200

200201
An integer, the default:ref:`protocol version<pickle-protocols>` used
201202
for pickling. May be less than:data:`HIGHEST_PROTOCOL`. Currently the
202-
default protocol is 4, first introduced in Python 3.4 and incompatible
203-
with previous versions.
203+
default protocol is 5, introduced in Python 3.8 and incompatible
204+
with previous versions. This version introduces support for out-of-band
205+
buffers, where:pep:`3118`-compatible data can be transmitted separately
206+
from the main pickle stream.
204207

205208
..versionchanged::3.0
206209

@@ -210,6 +213,10 @@ The :mod:`pickle` module provides the following constants:
210213

211214
The default protocol is 4.
212215

216+
..versionchanged::3.14
217+
218+
The default protocol is 5.
219+
213220
The:mod:`pickle` module provides the following functions to make the pickling
214221
process more convenient:
215222

‎Doc/whatsnew/3.14.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ symtable
115115
Optimizations
116116
=============
117117

118+
* Set the default protocol version on the:mod:`pickle` module to 5.
119+
For more details, please see:ref:`pickle protocols<pickle-protocols>`.
118120

119121

120122

‎Lib/pickle.py‎

Lines changed: 3 additions & 3 deletions
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
classPickleError(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 is4. It was introduced in Python 3.4, and
411+
The default protocol is5. It was introduced in Python 3.8, and
412412
is incompatible with previous versions.
413413
414414
Specifying a negative protocol version selects the highest
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump:mod:`pickle` default protocol to ``5``.

‎Modules/_pickle.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class _pickle.UnpicklerMemoProxy "UnpicklerMemoProxyObject *" ""
4040
already includes it. */
4141
enum {
4242
HIGHEST_PROTOCOL=5,
43-
DEFAULT_PROTOCOL=4
43+
DEFAULT_PROTOCOL=5
4444
};
4545

4646
#ifdefMS_WINDOWS
@@ -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 is4. It was introduced in Python 3.4, and is incompatible
4696+
protocol is5. It was introduced in Python 3.8, 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 is4. It was introduced in Python 3.4, and is incompatible
7507+
protocol is5. It was introduced in Python 3.8, 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 is4. It was introduced in Python 3.4, and is incompatible
7578+
protocol is5. It was introduced in Python 3.8, and is incompatible
75797579
with previous versions.
75807580
75817581
Specifying a negative protocol version selects the highest protocol

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp