Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit deb75f5

Browse files
committed
Removed some unused imports to decrease the amount of loaded modules during startup.
Added fallback to _dummy_thread for OSs w/o thread support.
1 parent 34ed9f7 commit deb75f5

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Lib/io.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@
6060
import sys
6161
import codecs
6262
import _fileio
63-
import warnings
64-
from _thread import allocate_lock as Lock
63+
# Import _thread instead of threading to reduce startup cost
64+
try:
65+
from _thread import allocate_lock as Lock
66+
except ImportError:
67+
from _dummy_thread import allocate_lock as Lock
68+
6569

6670
# open() uses st_blksize whenever we can
6771
DEFAULT_BUFFER_SIZE = 8 * 1024 # bytes

Lib/warnings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# See bug 683658.
66
import linecache
77
import sys
8-
import types
98

109
__all__ = ["warn", "showwarning", "formatwarning", "filterwarnings",
1110
"resetwarnings"]

0 commit comments

Comments
 (0)