Learning Python: Chapter 2
How Python Runs Programs
When the Python package is installed on the machine, it generates a number of components — minimally an interpreter and support library. The python code your write is always run by this interpreter.
An interpreter is a kind of program that executes other programs.
The python interpreter is a program that runs the programs that you write.
The standard execution model
When a program is executed,
- Python first compiles the source code into a format known an byte code which is platform independent. This is performed to speed execution. If the python process has write access on your machine, it will store the byte code in files that end with a .pyc extension(compiled .py code). Usually, .pyc byte code files will be saved in a subdirectory named pycache.
- This byte code is then shipped off for execution to the Python Virtual Machine(PVM). PVM(In C and C++, CPU executes the machine code) is kind of a big code loop that iterates through your byte code instructions, one by on e to carry out their operations.
All these components together form the python interpreter.
There are several variations for this standard execution model(by replacing byte code and VMs or by adding tools and Just In Time Compilers)
So there is no pre-compile and link steps in program execution. This makes for a much more rapid development cycle.
Python language has several implementations. PyPy is just one of them(It targets speed).