module import performance question

Emile van Sebille emile at
Tue Nov 11 16:25:14 CET 2003

"Jeff Sykes" <jeff at> wrote in message
news:729b56c7.0311102210.4869d4f6 at
> I have a cgi script that imports modules based on a user config
> I am suffering some performance problems when I import these
> Some logging revealed that it seems to be taking about 1.3 seconds
> import these modules. This is running on a Windows 2000 box with a
> Pentium II 400 processor, Python 2.1, Apache 1.3.19 as the web
> I don't need screaming performance numbers, but this time is
> excessive. Is it me, or does that number seem kind of slow?

How many modules are being imported?

> Any code
> optimizations or recommendations?

Don't append to sys.path.  Try sys.path.insert(0,addlpath).  Then the
import will get an immediate hit and always the right module rather
than stepping through all the preceeding directories.


Emile van Sebille
emile at

More information about the Python-list mailing list