Understanding the Execution of Python Program
Python
A kind of script language, interpret at the execution rather than compiling.
Application
web development
scientific computation
machine learning
What would Happen When We Execute the Python Source File.
The actions after python <SOURCE_FILE>.py
CPython(Interpreter) would first translate our source file into the byte codes.
The translated byte code would cache in
__pycache__
directory and named with.pyc
suffix.After translated to the byte code, the byte code could be executed on the
PVM(Python Virtual Machine)
.
JIT(Just In Time Compile)
Due to the byte code instructions execute on the virtual machine is not the behavior on our processor in physically, so here’s why JIT comes out.
Analyzing the byte code at run-time and compile to the machine code that our processor can read directly.
The machine code is optimized according to our run-time behavior.
Comparing Interpreter and Compiler
Interpreter | Compiler | |
---|---|---|
Run Time Execution | Slow | Fast |
Debug | Easy | Annoying |