What are the advantages and disadvantages of various implementations of python?

When it comes to Python, it generally refers to CPython. But Python is actually a language specification. It just defines which language elements Python should have and what tasks it should be able to accomplish. This language specification can be implemented in different ways. It can be implemented in C. It can also be implemented in C++, Java, C#, JavaScript, or even Python itself. This article briefly introduces and compares different Python implementations and will continue to expand in the future.

CPython

CPython is standard Python and is a reference implementation for other Python compilers. The term "Python" is usually used to refer to CPython. CPython is written by C and compiles the Python source code into CPython bytecodes that are interpreted and executed by the virtual machine. Without the use of technologies such as JIT, the use of reference counts in garbage collection.

So when someone asks whether Python is interpreting or compiling, you can answer this question: Python (CPython) compiles the Python source code into CPython bytecodes, which are then interpreted by the virtual machine to execute these bytecodes.

If you need to make extensive use of third-party extensions written in C, or make most of your users use your Python code directly, then use CPython.

Jython

Jython Python implemented on the JVM, written in Java. Jython compiles the Python source code into JVM bytecode, and the JVM executes the corresponding bytecode. Therefore, it can be well integrated with the JVM. For example, the JVM's garbage collection and JIT can be used to directly import and call libraries and functions written in other languages ​​on the JVM.

Jython is highly recommended for users who want to use Python to simplify workflows on the JVM, or for some reason need to use Java-related code in the Python language, while not using too many CPython extensions.

IronPython

IronPython is similar to Jython. The difference is that IronPython implements Python on the CLR, that is, on the .NET platform, written by C#. IronPython compiles the source code into TODO CLR, which also integrates well with the .NET platform. That is, like Jython, you can use the .NET framework's JIT, garbage collection, and other functions to import and call libraries and functions written in other languages ​​on .NET. IronPython uses Unicode strings by default.

In addition, Python Tools for Visual Studio can seamlessly integrate CPython and IronPython into VS. If you only need to develop larger Python projects on Windows. IronPython is a good choice if conditions permit.

PyPy

PyPy is used here to refer to Python implemented using Tracing JIT technology instead of the RPython tool chain. PyPy can choose from a variety of garbage collection methods, such as mark removal, mark compression, and generational generation.

For PPython, PyPy's performance improvement is very obvious, but the support for third-party modules is really weak. For example, extensions written using CPython's C API cannot be well supported, and extensions written using tools such as SWIG and SIP are not supported at all. Even NumPy has to be implemented from scratch at the compiler level. Even if implemented, it can only be used at the Python level and cannot be used by other third-party modules in a non-Python environment. About PyPy, follow-up will try to introduce a complete article. However, my article in this article has a more detailed description of PyPy and the following Pyston.

Pyston

Pyston was developed by Dropbox and written in C++11 using Method-at-a-time-JIT and Mark Sweep, Stop's World GC. Pyston uses a multi-level compilation like JavaScript V8, which also uses LLVM to optimize the code. Pyston is still under development and immature. But its prospects are very promising (if not as dead as Google’s Unladen Swallow.) In other words, Google’s things are getting more and more useless now, not because their stuff is not good, but they are afraid to use them. Turn it off.)

to sum up

Here are a few Python implementations of the main (actually, I have contacted ^_^), these Python implementations can meet most of the needs. And skipped a few paragraphs, such as Cython, Brython, RubyPython and so on. In fact, Cython is still very useful, but not much contact now, do not dare to write more to see if you can take the time to make up. With Brython and RubyPython, personal feelings can be used entirely in JS or Ruby. It is not necessary to use another dynamic language in a dynamic language environment.

AC Servo Motor

Ac Motor,220V Servo Motor,Ac Motor With Speed Controller,Remote Motor With Speed Controller

NingBo BeiLun HengFeng Electromotor Manufacture Co.,Ltd. , https://www.hengfengmotor.com