[issue25159] Regression in time to import a module

Terry J. Reedy report at bugs.python.org
Sat Sep 19 08:44:40 CEST 2015


Terry J. Reedy added the comment:

I did not find any significant different between 3.4 and 3.5 on Windows running the following:

import os, time
from importlib import import_module

files = os.listdir("C:/Programs/Python34/Lib")
excludes = {'antigravity.py', 'compileall.py', 'crypt.py', 'pty.py',
            'this.py', 'tty.py', '__phello__.foo.py'}
start = time.monotonic()
for name in files:
    if name.endswith('.py') and name not in excludes:
        try:
            import_module(name[:-3])
        except:
            print(name)
print(time.monotonic()-start)

Other than a couple of outliers, the time was consintly about .29 seconds with both 3.4 and 3.5:
  F:\Python\dev>py -3.x  c:/programs/python34/tem.py
The 3.5 run is a bit odd since it runs both 3.4 code and 3.5 code, but there were no extra exceptions once I added the needed exclusions (pyt and tty are also unix only) for 3.4.  The same code runs equally faster with Idle (.17 seconds), but that must be because Idle has already imported so many more /Lib modules (not including idlelib/*) than python itself.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25159>
_______________________________________


More information about the Python-bugs-list mailing list