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:
Georg Brandl 2006-05-26 18:03:31 +00:00
parent 2d6c5a868a
commit f4ef11659c
3 changed files with 38 additions and 4 deletions

View file

@ -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