Questions about "compiled" Python (beginner)

HoneyMonster someone at someplace.invalid
Sun Jan 29 12:57:10 EST 2012

I am new to Python (Python 2.7 on Linux). Research indicates that:

a) "Compiling" Python modules into intermediate bytecode marginally 
improves load time.

b) The Python interpreter will use an already-prepared .pyc file if one 
exists in the same directory as the .py.

That then, is presumably why for every .py file in my site-packages 
directory there is a corresponding .pyc file.

Question 1: What then, are the .pyo files? I note that many of them are 
identical to the .pyc, but that some differ.

Question 2: What happens if the .py file is changed and the .pyc is thus 
made obsolete. Does the interpreter ignore the .pyc? If so, how does it 
know? By the timestamp?


More information about the Python-list mailing list