Skip to content

Commit ff3e145

Browse files
picnixzAA-Turner
andauthored
gh-118761: Improve import time of the pickle module. (#128732)
Importing `pickle` is now roughly 25% faster. Importing the `re` module is no longer needed and thus `re` is no more implicitly exposed as `pickle.re`. --------- Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 1153e66 commit ff3e145

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/pickle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import sys
3232
from sys import maxsize
3333
from struct import pack, unpack
34-
import re
3534
import io
3635
import codecs
3736
import _compat_pickle
@@ -188,7 +187,7 @@ def __init__(self, value):
188187
NEXT_BUFFER = b'\x97' # push next out-of-band buffer
189188
READONLY_BUFFER = b'\x98' # make top of stack readonly
190189

191-
__all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$", x)])
190+
__all__.extend(x for x in dir() if x.isupper() and not x.startswith('_'))
192191

193192

194193
class _Framer:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Improve import time of :mod:`pickle` by 25% by removing an unnecessary
2+
regular expression. As such, :mod:`re` is no more implicitly available
3+
as ``pickle.re``. Patch by Bénédikt Tran.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy