.pyc files??

Jeremy Jones zanesdad at bellsouth.net
Wed Sep 1 20:59:04 EDT 2004


Ishwar Rattan wrote:

>Say a filea.py contains a number of functions defined in it (using
>def afn(): etc.)
>
>in pyhton, filea is imported to use afn (filea.afn() etc.), it cerates
>a filea.pyc file, what is the purpose of this file?
>
>-ishwar
>  
>
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).




More information about the Python-list mailing list