Skip to content

Commit e994e02

Browse files
committed
Improve import time of the pickle module.
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`.
1 parent aef52ca commit e994e02

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Lib/pickle.py

Lines changed: 4 additions & 3 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,8 +187,10 @@ 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)])
192-
190+
__all__.extend([
191+
x for x in dir()
192+
if x.isupper() and x.isidentifier() and not x.startswith('_')
193+
])
193194

194195
class _Framer:
195196

0 commit comments

Comments
 (0)