.pyc files??

Peter Hansen peter at engcorp.com
Wed Sep 1 21:17:42 EDT 2004


Jeremy Jones wrote:

> This file contains compiled bytecode that the Python interpreter uses.  
> If, in your example, filea.pyc exists and its timestamp is newer than 
> filea.py, then the interpreter uses filea.pyc without even attempting to 
> recompile it (which saves the time spent compiling in subsequent runs).  
> If filea.pyc doesn't exist, or its timestamp is older than filea.py, the 
> Python interpreter compiles filea.py to bytecode and writes it to 
> filea.pyc (if it has permissions to do so).

Minor nit-picking:  I'm fairly sure that the interpreter just compares
the timestamp for equality, not for "earlier than".  I could be
wrong, but I think it's a case of "if the .pyc embedded timestamp
doesn't match the timestamp of the corresponding .py file exactly,
then recompile the .pyc file".

And a quick test at the command line appears to confirm this...

-Peter



More information about the Python-list mailing list