[Python-Dev] requirements for moving __import__ over to importlib?

Terry Reedy tjreedy at udel.edu
Fri Feb 10 04:14:16 CET 2012


On 2/9/2012 7:19 PM, PJ Eby wrote:

> Right.  It was the part of the post that mentioned that all they sped up
> was knowing which directory the files were in, not the actual loading of
> bytecode.  The thought then occurred to me that this could perhaps be
> applied to normal importing, as a zipimport-style speedup.  (The
> zipimport module caches each zipfile directory it finds on sys.path, so
> failed import lookups are extremely fast.)
>
> It occurs to me, too, that applying the caching trick to *only* the
> stdlib directories would still be a win as soon as you have between four
> and eight site-packages (or user specific site-packages) imports in an
> application, so it might be worth applying unconditionally to
> system-defined stdlib (non-site) directories.

It might be worthwhile to store a single file in in the directory that 
contains /Lib with the info inport needs to get files in /Lib and its 
subdirs, and check that it is not outdated relative to /Lib. Since in 
Python 3, .pyc files go in __pycache__, if /Lib included an empyty 
__pycache__ on installation, /Lib would never be touched on most 
installations. Ditto for the non-__pycache__ subdirs.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list