
Everyone tries to be a master in python. But No one wants to know the actual logic and processing of this language , How does python internally works.
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Python programs are also platform independent. Once we write a Python program, it can run on any platform without rewriting once again. Python uses PVM to convert python code to machine understandable code. Now let us see the internal workings of python, before going in-depth into the technical concepts let us try to understand few technical terms to have a better understanding.
What is PVM?
We know that computers understand only machine code that comprises 1s and 0s. Since computer understands only machine code, it is imperative that we should convert any program into machine code before it is submitted to the computer for execution. For this purpose, we should take the help of a compiler. A compiler normally converts the program source code into machine code.
A Python compiler does the same task but in a slightly different manner. It converts the program source code into another code, called byte code. Each Python program statement is converted into a group of byte code instructions.
Python Virtual Machine (PVM) takes those byte codes converts those instructions into machine code so that the computer can execute those machine code instructions and display the final output. To carry out this conversion, PVM is equipped with an interpreter. The interpreter converts the byte code into machine code and sends that machine code to the computer processor for execution. Since interpreter is playing the main role, often the Python Virtual Machine is also called an interpreter.
Press enter or click to view image in full size