What’s Python Interpreter?

When we write Python code, we get a text file with Python code with .py as the extension. To run the code, you need the Python interpreter to execute the .py file.

Since the entire Python language is open source from specification to interpreter, in theory, as long as the level is high enough, anyone can write Python interpreters to implement Python code (of course, very difficult). In fact, there are a variety of Python interpreters.

CPython

When we downloaded and installed Python 3.5 from the official Python website, we went directly to an official version of the interpreter: CPython. This interpreter is developed in C language, so-called CPython. Running the python at the command line starts the CPython interpreter.

CPython is the most widely used Python interpreter. All the code for the tutorial is also executed under CPython.

IPython

IPython is based on an interactive interpreter on top of CPython, that is, IPython is only enhanced in interactive mode, but the implementation of Python code and CPython is exactly the same. Like many domestic browsers, although the appearance is different, the kernel is actually called IE.

CPython uses >>> as a prompt, and IPython uses In [serial number]: as a prompt.

PyPy

PyPy is another Python interpreter whose goal is to execute speed. PyPy uses JIT technology to dynamically compile Python code (note not to explain), so you can significantly improve the speed of Python code execution.

Most Python code can run under PyPy, but some of PyPy and CPython are different, which causes the same Python code to execute under the two interpreters, which may have different results. If your code is to be executed under PyPy, you need to understand the differences between PyPy and CPython.

Jython

Jython is a Python interpreter running on the Java platform that can be compiled directly into Java bytecode.

IronPython

IronPython is similar to Jython, except that IronPython is a Python interpreter running on the Microsoft.Net platform and can compile Python code directly into. Net bytecode.

summary

Python interpreter is a lot, but the most widely used or CPython. If you want to interact with the Java or. Net platform, the best way is not to use Jython or IronPython. But through the network, call to interact, to ensure the independence between the various procedures.