The Python interpreter

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

Since the entire Python language, from specification to interpreter, is open source, anyone with a high enough standard can theoretically write a Python interpreter to execute Python code (which is difficult, of course). In fact, there are many Python interpreters.

CPython

When we downloaded Python 3.x from the Official Python website and installed it, we immediately got the official version of the interpreter: CPython. This interpreter was developed in C, so it's called CPython. Running Python from the command line starts the CPython interpreter.

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

IPython

IPython is an interactive interpreter based on CPython, that is, IPython only enhances the way it interacts, but executes Python code exactly as CPython does. Like many domestic browsers although the appearance is different, but the kernel is actually called IE.

CPython USES >>> as the prompt, while IPython USES In [sequence number]: as the prompt.

PyPy

PyPy is another Python interpreter whose goal is execution speed. PyPy USES JIT technology to dynamically compile (not interpret) Python code, so it can significantly speed up the execution of Python code.

Most Python code can be run under PyPy, but there are some differences between PyPy and CPython, resulting in the possibility that the same Python code executed under either interpreter will 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 compiles Python code directly for Java bytecode execution.

IronPython

IronPython is similar to Jython, except that IronPython is a Python interpreter that runs on the Microsoft.NET platform and compiles Python code directly into.NET bytecode.

Summary

There are many Python interpreters, but the most widely used one is CPython. If you want to interact with the Java or.NET platform, the best way to do this is not with Jython or IronPython, but with network calls to ensure independence between programs.

All of the code in this tutorial is guaranteed to run under CPython 3.x only. Be sure to install CPython locally (that is, from the official Python web site).

Leave a Reply

Your email address will not be published. Required fields are marked *