[Python-Dev] updated imputil

Greg Stein gstein@lyra.org
Sat, 20 Nov 1999 04:06:48 -0800 (PST)


I've updated imputil... The main changes is that I added SysPathImporter
and BuiltinImporter. I also did some restructing to help with
bootstrapping the module (remove dependence on os.py).

For testing a revamped Python import system, you can importing the thing
and call imputil._test_revamp() to set it up. This will load normal,
builtin, and frozen modules via imputil. Dynamic modules are still
handled by Python, however.

I ran a timing comparisons of importing all modules in /usr/lib/python1.5
(using standard and imputil-based importing). The standard mechanism can
do it in about 8.8 seconds. Through imputil, it does it in about 13.0
seconds. Note that I haven't profiled/optimized any of the Importer stuff
(yet).

The point about dynamic modules actually discovered a basic problem that I
need to resolve now. The current imputil assumes that if a particular
Importer loaded the top-level module in a package, then that Importer is
responsible for loading all other modules within that package. In my
particular test, I tried to import "xml.parsers.pyexpat". The two package
modules were handled by SysPathImporter. The pyexpat module is a dynamic
load module, so it is *not* handled by the Importer -- bam. Failure.

Basically, each part of "xml.parsers.pyexpat" may need to use a different
Importer...

Off to ponder,
-g

-- 
Greg Stein, http://www.lyra.org/