Home > Article > Backend Development > The difference between python compiler and interpreter
High-level languages cannot be directly understood and executed by machines, so they all require a translation stage. Interpreted languages use an interpreter, and compiled languages use a compiler.
The usual execution process of a compiled language is: source code - preprocessor - compiler - object code - linker - executable program.
In a sense, preprocessing is actually an additional function. C and PHP can add this function. Among them, preprocessing instructions are mostly header files. Contains, macro definitions, etc. Because the core of macro definition is simply the word "change", preprocessing is to provide an environment for program execution.
Compiler - target code is to convert high-level programming language into machine language that the machine can understand and execute.
Related recommendations: "Python Video Tutorial"
Before you start to understand the functions of the linker, you need to understand a little bit first. The header files are compiled into individual files during preprocessing, that is, library files. The program is another file and is not included in the library file. So this requires a "glue" to connect the program and library to form an executable file (EXE in Windows). This is what the linker does.
The interpreter makes it easy to understand. You can understand and execute the program line by line. First, read a line of code, then execute the meaning of this line of code, then read the next line of code, and execute the next line of code. A cycle over and over again.
The compiler reads in all the code, packages it into an executable file, and executes it. Since we generally run compiled executable files, that is, they execute machine language (and are optimized by IDE), so the running speed is faster than interpreted languages.
The above is the detailed content of The difference between python compiler and interpreter. For more information, please follow other related articles on the PHP Chinese website!