Python is an interpreted language, when executing Python, the interpreter translates the source code in bytecode into byte code, and then the byte code is given to the Python virtual machine PVM to execute, as shown in the process:
BYTE code
1 byte code translation
The Python interpreter does not always translate source code into bytecode byte code. For example, if you do not make any changes to the source code, when you execute the Python program, the Python interpreter simply hands the bytecode to the Python virtual machine and skips the steps of translating the source code into bytecode. In the following two scenarios, the Python interpreter will re-translate the source code into bytecode:
1 The source code is changed. The Python interpreter checks the time stamp of the source code and bytecode, and if the source code is found to be modified, it will be re-translated.
2 python version changed. If the Python interpreter finds that the version information contained in the bytecode does not match the current Python version, it will be re-translated. For Python implementations prior to <python3.2, the version information is contained in a "magic" version number in the bytecode file, and for the Python implementation of >=python3.2, the bytecode file name contains the version information
2 byte-code storage location
The python bytecode suffix "pyc" represents the complied.py file. For <python3.2 implementation, the bytecode file is placed in the same directory as the source file, and for the implementation of >=python3.2, the bytecode file is placed separately under a __pycache__ folder, and the __pycache__ folder is in the same directory as the source file. And the bytecode files stored under __pycache__ contain Python version information, such as SCRIPT-33.PYC, which indicates that the current bytecode is translated by the Python3.3 implementation.
Pvm
Python virtual machines do not need to be installed separately, it is part of the Python implementation, essentially a large loop, a sentence to execute the code inside the bytecode
How Python Works