PVM (Python Virtual Machine)

As a programmer, we all know that a computer only understands machine language and every programming language converts its code to machine language. This is done by a compiler of that language. The Python compiler also does the same thing but in a slightly different manner.
 
When we run a Python program, two steps happen,
  1. The code gets converted to another representation called ‘Byte Code’
  2. ‘Byte Code’ gets converted to Machine Code (which is understandable by the computer)
The second step is being done by PVM or Python Virtual Memory. So PVM is nothing but a software/interpreter that converts the byte code to machine code for given operating system.
 
PVM is also called Python Interpreter and this is the reason Python is called an Interpreted language.
 
PVM(Python Virtual Machine) 
We can’t see the Byte Code of the program because this happens internally in memory.
 
But if we want to see the byte code of the program execute the below command:
 
D:\> python -m py_complie x.py
 
Here we are calling the Python compiler with the  -m option. -m represents module and the module name is py_compile. This module generates the .pyc file for .py file. *.pyc file contains the byte code of the Python program. One can open and see the byte code representation of the python program. To convert byte code into machine code/output use:
 
D:\> python <nameofpycfile>.pyc
 
Here Python would skip the step of byte code generation and would convert byte code directly to machine code.
 
That’s the reason, while delivering python projects,  *.pyc files are given with PVM so that users can see the output directly.
 
I hope this helps in gaining a deep understanding of Python