Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-118761: improve import time for pickle #128732

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Lib/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import sys
from sys import maxsize
from struct import pack, unpack
import re
import io
import codecs
import _compat_pickle
Expand Down Expand Up @@ -188,8 +187,10 @@ def __init__(self, value):
NEXT_BUFFER = b'\x97' # push next out-of-band buffer
READONLY_BUFFER = b'\x98' # make top of stack readonly

__all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$", x)])

__all__.extend([
x for x in dir()
if x.isupper() and x.isidentifier() and not x.startswith('_')
])
picnixz marked this conversation as resolved.
Show resolved Hide resolved

class _Framer:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improve import time of :mod:`pickle` by 25% by removing an un-necessary
import to :mod:`re`. Patch by Bénédikt Tran.
Loading