Home >Backend Development >Python Tutorial >Is python an interpreted language?

Is python an interpreted language?

藏色散人
藏色散人Original
2019-06-27 09:21:2910725browse

Is python an interpreted language?

Is python an interpreted language?

Python is not entirely an interpreted language. It is compiled. The source code py file is first compiled into pyc or pyo, and then executed by the python virtual machine. Compared with the py file, compilation In essence, pyc and pyo are not much different from py, but the loading speed of this module is increased, and the execution speed of the code is not improved. Normally, there is no need to actively compile the pyc file. The document says that as long as the import model is called, then model.py will first be compiled into pyc and then loaded.

In fact, Python, like Java/C#, is also a language based on a virtual machine. Let’s first briefly understand the running process of the Python program from the surface.

When we enter python hello.py on the command line, we actually activate the Python "interpreter" and tell the "interpreter": You are about to start working.

But before "interpretation", the first work performed is actually the same as Java, which is compilation.

Students who are familiar with Java can think about how we execute a Java program on the command line:

javac hello.java
java hello

It’s just that when we use IDEs such as Eclipse, we integrate these two parts into Just one piece. In fact, the same is true for Python. When we execute python hello.py, it also executes such a process, so we should describe Python like this. Python is a language that is compiled first and then interpreted.

Related recommendations: "Python Tutorial"

The above is the detailed content of Is python an interpreted language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn