Skip to content

Commit

Permalink
Improve import time of the pickle module.
Browse files Browse the repository at this point in the history
Importing `pickle` is now roughly 25% faster.

Importing the `re` module is no longer needed and
thus is no more implicitly exposed as `pickle.re`.
  • Loading branch information
picnixz committed Jan 11, 2025
1 parent aef52ca commit e994e02
Showing 1 changed file with 4 additions and 3 deletions.
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('_')
])

class _Framer:

Expand Down

0 comments on commit e994e02

Please sign in to comment.