cpython/Lib/importlib
Brett Cannon 58f5680462 Issue #18810: Be optimistic with stat calls when seeing if a directory
exists when checking for a package.

Before there was an isdir check and then various isfile checks for
possible __init__ files when looking for a package.
This change drops the isdir check by leaning
on the assumption that a directory will not contain something named
after the module being imported which is not a directory. If the module
is a package then it saves a stat call. If there is nothing in the
directory with the potential package name it also saves a stat call.
Only if there is something in the directory named the same thing as
the potential package will the number of stat calls increase
(due to more wasteful __init__ checks).

Semantically there is no change as the isdir check moved
down so that namespace packages continue to have no chance of
accidentally collecting non-existent directories.
2013-10-18 13:24:13 -04:00
..
__init__.py Closes issue #18698: ensure importlib.reload() returns the module out of sys.modules. 2013-08-14 18:11:09 -06:00
_bootstrap.py Issue #18810: Be optimistic with stat calls when seeing if a directory 2013-10-18 13:24:13 -04:00
abc.py [issue 19152] Ensure we have actually registered ExtensionFileLoader as an ExecutionLoader. 2013-10-04 20:28:52 -06:00
machinery.py Issue #15576: Allow extension modules to be a package's __init__ 2012-08-10 13:47:54 -04:00
util.py Issue #18076: Introduce imoportlib.util.decode_source(). 2013-06-16 18:37:53 -04:00