Guido van Rossum wrote:
On 4/20/06, "Martin v. Löwis" email@example.com wrote:
- don't load packages out of .zip files. It's not that bad if software on the user's disk occupies multiple files, as long as there is a convenient way to get rid of them at once. Many problems go away if you just say no to zipimport.
You forget that importing from a zip file is often much faster than importing from the filesystem. That's why zipimport was added in the first place.
This is true if you only have a single ZIP file, e.g. python24.zip on sys.path.
It is not if you have dozens of ZIP files on sys.path, since you have to take the initial scan time plus the memory for caching the ZIP file contents into account. Each ZIp file adds to Python startup time, since the ZIP files on sys.path are scanned for every Python startup.
Here's an example of the effect of having just 20 eggs on sys.path:
tmp/eggs> time python -S -c '0' 0.014u 0.006s 0:00.02 50.0% 0+0k 0+0io 0pf+0w tmp/eggs> unsetenv PYTHONPATH tmp/eggs> time python -S -c '0' 0.006u 0.003s 0:00.01 0.0% 0+0k 0+0io 0pf+0w
Startup time effectively doubles, even if you don't use any of the installed eggs in your script.
The main reason for adding zip imports was to simplify deploying (complete) applications to users, e.g. have the complete Python stdlib in one file.