python24.zip

Dieter Maurer dieter at handshake.de
Sun May 22 14:11:42 EDT 2005


"Martin v. Löwis" <martin at v.loewis.de> writes on Sat, 21 May 2005 23:53:31 +0200:
> Dieter Maurer wrote:
> ...
> > The question was:
> > 
> >    "should python start up with **non-existent** objects on the path".
> > 
> > I think there is no reason why path needs to contain an object
> > which does not exist (at the time the interpreter starts).
> 
> There is. When the interpreter starts, it doesn't know what object
> do or do not exist. So it must put python24.zip on the path
> just in case.

Really?

Is the interpreter unable to call "C" functions ("stat" for example)
to determine whether an object exists before it puts it on "path".

> Yes, but the interpreter cannot know in advance whether
> python24.zip will be there when it starts.

Thus, it checks dynamically when it starts.

> > I recently analysed excessive import times and
> > saw thousands of costly and unneccesary filesystem operations due to:
> 
> Hmm. In my Python 2.4 installation, I only get 154 open calls, and
> 63 stat calls on an empty Python file. So somebody must have messed
> with sys.path really badly if you saw thoughsands of file operations
> (although I wonder what operating system you use so that failing
> open operations are costly; most operating systems should do them
> very efficiently).

The application was Zope importing about 2.500 modules
from 2 zip files "zope.zip" and "python24.zip".
This resulted in about 12.500 opens -- about 4 times more
than would be expected -- about 10.000 of them failing opens.


Dieter



More information about the Python-list mailing list