[Python-Dev] new imputil.py

M.-A. Lemburg mal@lemburg.com
Mon, 03 Jan 2000 13:28:34 +0100


Happy New Year :-)

[new imputil.py]

I tried the new module with the following code:

import imputil,sys

if sys.argv[1] != 'standard':
    print 'Installing imputil...',
    imputil.ImportManager().install()
    sys.path.insert(0, imputil.BuiltinImporter())
    print 'done.'
else:
    print 'Using builtin importer.'

print

print 'Importing standard stuff...',
import string,re,os,sys
print 'done.'

print 'Importing mx Extensions...',
from mx import DateTime,TextTools,ODBC,HTMLTools,UID,URL
print 'done.'

###

The new importer does load everything in the test set
(top level modules, packages, extensions within packages)
without problems on Linux.

Some comments:

· Why is the sys.path.insert(0,imputil.BuiltinImporter()) 
needed in order to get b/w compatibility ?

· Why is there no __path__ aware code in imputil.py (this is
definitely needed in order to make it a drop-in replacement) ?

· Performance is still 50% of the Python builtin importer --
a bummer if you ask me. More aggressive caching is definitely
needed, perhaps even some recoding of methods in C.

· The old chaining code should be moved into a subclass of
its own.

· The code should not import strop directly as this module
will probably go away RSN. Use string methods instead.

· The design of the ImportManager has some minor flaws: the
FS importer should be settable via class attributes, deinstallation
should be possible, a query mechanism to find the importer
used by a certain import would also be nice to be able to
verify correct setup.

· py/pyc/pyo file piping hooks would be nice to allow
imports of signed (and trusted) code and/or encrypted code
(a mixin class for these filters would do the trick).

· Wish list: a distutils importer hooked to a list of standard
package repositories, a module to file location mapper to
speed up file system based imports, 

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                             Happy New Century !
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/