On Mon, Nov 05, 2012 at 02:15:53PM +0100, Marc Espie wrote:

> Turns out python is stupid enough to store path+timestamp in its compiled
> *.pyc files  to know when to recompile.

The "auto-recompile everything which is out of date" feature is ingenious but
there are at least two different ways of implementing it. One way is to check
the timestamps on X.py and X.pyc; if the latter is older than the former,
recompile, and (try to) cache the output to X.pyc. [This is how Converge
works, if anyone cares.] Judging by your comment, Python stores the timestamp
in the file itself (probably for portability/performance reasons) rather than
checking the timestamp from the filesystem. [I can't remember off-hand, nor
can I remember how PyPy does it either.]

I assume the only people who are having pkg_delete problems are running a
Python program as root? If so, in one sense, they're the lucky ones. The
unlucky ones would then be those running as non-root where the "is X.py newer
than X.pyc" check fails, forcing a recompilation, but which can't then save
out a cached file. So every time they run Python they'll be paying a
recompilation cost for such files.

The question this raises in my mind is the following. During an update, can
the timestamp of X.py be updated, but not X.pyc?

If so, then I think that would be a problem that pkg_update needs to fix:
timestamps (particularly the relative timestamps of files i.e. "X is older
than Y") are an important piece of meta-data.

If not, then it might be possible to make a case to the Python developers
that rather than storing timestamps in the pyc file, they should simply read
it from the filesystem. That would mean that both X.py and X.pyc could be
updated, but providing X.pyc is newer than X.py, Python would not try to
write out a cached file.


Laurie
-- 
Personal                                             http://tratt.net/laurie/
The Converge programming language                      http://convergepl.org/
   https://github.com/ltratt              http://twitter.com/laurencetratt

Reply via email to