python

Python Program Compilation

python

Python first compiles your source code (the statements in your file) into a format known as byte code. Compilation is simply a translation step, and byte code is a lower-level, and platform-independent, representation of your source code. Bytecode ends with .pyc extension. Byte code is saved only for files that are imported in the main file and not for the top-level file of a program.

Byte code is also never saved for code typed at the interactive prompt,

Once your program has been compiled to byte code (or the byte code has been loaded from .pyc files), it is shipped off for execution to something generally known as the Python Virtual Machine (PVM, for the more acronym-inclined among you). The PVM sounds more impressive than it is; really, it’s just a big loop that iterates through your byte code instructions, one by one, to carry out their operations. The PVM is the runtime engine of Python; it’s always present as part of the Python system, and is the component that truly runs your scripts. Technically, it’s just the last step of what is called the Python interpreter.

Please click here for more information on python program compilations. Google has plenty of notes on the same.

Leave a Reply