mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Need for speed: Patch #921466 : sys.path_importer_cache is now used to cache valid and
invalid file paths for the built-in import machinery which leads to fewer open calls on startup. Also fix issue with PEP 302 style import hooks which lead to more open() calls than necessary.
This commit is contained in:
parent
2d6c5a868a
commit
f4ef11659c
3 changed files with 38 additions and 4 deletions
|
@ -340,11 +340,13 @@ def get_importer(path_item):
|
|||
importer = None
|
||||
sys.path_importer_cache.setdefault(path_item, importer)
|
||||
|
||||
if importer is None:
|
||||
# The boolean values are used for caching valid and invalid
|
||||
# file paths for the built-in import machinery
|
||||
if importer in (None, True, False):
|
||||
try:
|
||||
importer = ImpImporter(path_item)
|
||||
except ImportError:
|
||||
pass
|
||||
importer = None
|
||||
return importer
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue