i don't use zipimport directly,just like u said i put the zip in the
sys.path
i found the the module in the zip reloaded everytime the code is
called,i mean, say ,first time it take me 1 second to call a method in
the zip,but it take another 1 second to call the mothod for another
time ,and so on
How do you know that it is being reloaded each time a methos is
called?
We can only guess if you don't show us what is actually happening.
Vague descriptions are not very useful. Show us how exactly you are
importing the modules, how you are calling methods, with timing
calls ...
By the way, have you read this part of the documentation:
"Note that if an archive only contains .py files, Python will not
attempt to modify the archive by adding the corresponding .pyc or .pyo
file, meaning that if a ZIP archive doesn't contain .pyc files,
importing may be rather slow."
?
Do you have .pyc files in your ZIP file? If not that would make the
first import slower than it should be.
However second, third, ... imports (if you do any) should be
instantaneous -- unless you are messing about deleting modules from
sys.modules.
And *method* calls should be instantaneous.
Does your app run at the same speed when you have all the modules in a
directory instead of inside a zip file?
Apart from code executed once at app start to inject the path to the
zip file into sys.path, have you made any other changes to accommodate
using import from zip? If so, what changes?
Have you tried running your app from the shell (Windows translation:
in a Command Prompt window) like this:
python -v app_start.py
This will show you all the imports as they happen.
HTH ... but a clear description from you (plus code samples) of
exactly what you are doing woul dhelp a whole lot more.
John