[Python-Dev] __file__

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Feb 28 02:51:16 CET 2010


Floris Bruynooghe wrote:
> (But even then I'm not
> convinced that would double the stat calls for normal users, only for
> those who only ship .pyc files)

It would increase the number of stat calls for normal
users by 50%. You would need to look for a .pyc in the
source directory, then .py in the source directory and
.pyc in the cache directory. That's compared to two
stat calls currently, for .py and .pyc.

A solution might be to look for the presence of the
cache directory, and only look for a .pyc in the source
directory if there is no cache directory. Testing for
the cache directory would only have to be done once
per package and the result remembered, so it would
add very little overhead.

-- 
Greg



More information about the Python-Dev mailing list