how to optimize zipimport

John Machin sjmachin at
Thu Mar 26 06:38:09 CET 2009

On Mar 26, 2:06 pm, Coonay <fla... at> wrote:
> see,the zipimort takes nearly 0.5 second
> D 03-25 07:53PM 21.374
> Loading __main__
> I 03-25 07:53PM 21.455
> zipimporter('/base/data/home/apps/coonay/1.332322118600950324/
>', '')

?? zipimport.Zipimporter() has one arg, not two.

> W 03-25 07:53PM 22.046
> appengine_django module
> On Mar 26, 10:41 am, Coonay <fla... at> wrote:
> > in my mudule ,i import another mudule from a zip ,
> > when i call  my mudle method,the module in the zip will be import from
> > the zip every time,that slow down the operation,
> > i try to search the some workarodnd or solution but i don't get one,

Why are you explicitly using the zipimport module? In other words, why
don't you put the full path of the zip file in sys.path and then just
use the normal "import module_in_the_zip" mechanism? Note that this
can/should be done once at the top of your calling module. In other
words, the import code is executed when the calling module is imported
by your main script, not every time you call a method in your calling

Alternatively, if you feel you *must* use zipimport, what's to stop
you doing that once at the top of the calling module?

Note: it may help when you reply to show a stripped-down version of
your calling module, sufficient to back up your description of what is


More information about the Python-list mailing list