[Python-Dev] Re: Change to sys.path[0] for Python 2.3

Jack Jansen jack@oratrix.nl
Tue, 27 Nov 2001 15:27:40 +0100


> I am not happy with changing current directories because I am trying
> to speed up imports, and it is harder to cache directory contents
> on multiple operating systems.  But I can do it if we need to.

Ah, at least now I understand what you're trying to do. BUT: have you done any 
measurements that show that this caching is actually beneficial? For many 
years we've used a special caching importer in a very big Python project here, 
and when we finally did some real measurements it turned out that it had 
slowed down imports all that time in stead of speeding them up.

You have to be especially aware of NFS mounted filesystems.

Hmm, why not cache on a sys.path entry-by-entry basis? Then, if the entry is a 
zipfile we always cache, if the entry is a relative pathname we never cache, 
if the entry is an absolute pathname we cache on the basis of a preference. 
Use the sys.path entry as a key in a dictionary, the result is either None 
(don't cache) or the cache for this sys.path entry. If the key isn't found 
this is the first time we come across this sys.path entry so we decide whether 
to cache or not.

--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.cwi.nl/~jack        | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm