Does python always need to compile ENTIRE program before it c an start to run it???
lance.ellinghaus at eds.com
Mon Nov 3 20:40:45 CET 2003
Python always compiles your scripts to bytecode before it can be executed.
It cannot and does not do partial compilation and execution.
But this is not the whole story. Python does not always have to do the
compilation phase. When Python loads a module (.py file) from an 'import'
statement, it will see if there is an already compiled version in the same
directory and named the same except for the '.pyc' or '.pyo' extension. If
it finds this file AND it is newer than the corresponding source code (.py)
then it will load the saved compilation and then run it. If the file is not
found or it is older than the source, then Python will compile the source,
attempt to save the compiled version, and then it will execute it.
I hope this helps answer your question.
EDS - TWAI Operations
From: seberino at spawar.navy.mil [mailto:seberino at spawar.navy.mil]
Sent: Monday, November 03, 2003 1:45 PM
To: python-list at python.org
Subject: Does python always need to compile ENTIRE program before it can
start to run it???
I can achieve something similar to Python's automatic compilation in C/C++
by making a script that compiles and runs my program like this:
make ; myprogram
I am trying to think of an advantage Python has over this hack....
Is it true that unlike C/C++ that Python programs can start executing before
compilation is COMPLETELY done??? I think so but I'm not sure.
More information about the Python-list