diff options
author | Georg Brandl <georg@python.org> | 2006-05-26 18:03:31 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-05-26 18:03:31 (GMT) |
commit | f4ef11659cda2ef0d56df499525818a132e6836a (patch) | |
tree | 56ba66b5433f01d43438f2a99f1238dd4b4e2dac /Lib/pkgutil.py | |
parent | 2d6c5a868afa5e38f168ffde955efb5bc4db4c2b (diff) | |
download | cpython-f4ef11659cda2ef0d56df499525818a132e6836a.zip cpython-f4ef11659cda2ef0d56df499525818a132e6836a.tar.gz cpython-f4ef11659cda2ef0d56df499525818a132e6836a.tar.bz2 |
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.
Diffstat (limited to 'Lib/pkgutil.py')
-rw-r--r-- | Lib/pkgutil.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py index ddf2a72..26c797f 100644 --- a/Lib/pkgutil.py +++ b/Lib/pkgutil.py @@ -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 |