Actually Python
is both interpreted and compiled language. The question is how Python
run the code.
-
- So, at first we write a
Python
code stored in a file with.py
extension. Then a compiler compiled the source code into specialbyte code
at that time the compiler also checks thePython
syntax.
- So, at first we write a
-
- The
Python
compiler compiled the code behind the scene so we don't have to compile it manually.
- The
-
- The
byte code
is not understand bycpu
.
- The
-
- Now, there is an
Interpreter
which is also calledPython Virtual Environment(PVM)
which takes that byte code and read the byte code line by line (one line at a time) and convert that byte code intoMachine Code
.
- Now, there is an
-
- Here we use byte code for portability.So every computer should have virtual machine (PVM) to interpreted that byte code.
-
- The python code we write is actually CPython.
-
- All language have one compiling phase. So, no language is only interpreted that language is also compiled.