[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Distutils] formencode as .egg in Debian ??



Phillip J. Eby wrote:
<snip>
Note also that in many cases, the package will be a single .egg file,
(analagous to a Java .jar file) rather than a directory, and files are
preferable to directories in most cases as they make Python import
processing faster.
<snip>


Yes, it's true, zipfile import processing is faster than normal import processing; it is in fact one of the reasons zipfile imports were added to Python, because the zip directories are cached. A zipfile import lookup is a single dictionary lookup, whereas a directory import lookup requires multiple stat() calls. For all practical purposes, zipfiles added to sys.path are free after the initial directory read operation.

Maybe an easier way to understand this (at least my impression) is that zip files are treated as read-only. Any directory on sys.path gets scanned everytime a new module is imported. And you never know if someone added something, so you do it all over again each time. A zip file is scanned only once.


--
Ian Bicking  /  ianb@colorstudy.com  /  http://blog.ianbicking.org



Reply to: