无他,唯手熟尔!

Python interpreter

When we write Python code, we get a text file with a .py extension of Python code. To run the code, you need a 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 a Python interpreter to execute Python code (of course it is very difficult). In fact, there are indeed a variety of Python interpreters.

CPython
When we downloaded and installed Python 3.x from the official Python website, we got an official version of the interpreter: CPython. This interpreter was developed in C, so it is called CPython. Running python from the command line is to start 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 an interactive interpreter based on CPython, which means that IPython is only enhanced in terms of interaction, but the functionality of executing Python code is exactly the same as CPython. For example, many domestic browsers have different appearances, but the kernel actually calls IE.

CPython uses >>> as the prompt, while IPython uses In [serial]: as the prompt.

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

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

Jython
Jython is a Python interpreter that runs on the Java platform and can be compiled directly into Java bytecode for execution.

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

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

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

赞(0) 打赏
未经允许不得转载:沙の志 » Python interpreter

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

沙の志