Home  >  Article  >  Backend Development  >  The performance of Python 3.11 has improved by nearly 64%!

The performance of Python 3.11 has improved by nearly 64%!

王林
王林forward
2023-04-24 12:46:071303browse

The performance of Python 3.11 has improved by nearly 64%!

It’s no secret that Python is not a fast programming language. Many developers are looking forward to improvements in the performance of this language. This situation may be about to change, or at least moving in the right direction. This is also one of the results of the decision-making of Python's founder after he returned to work.

On May 7, the Python team released the latest Python version - Python 3.11. What is currently released is a beta version (Beta1) for developers to use for testing or experimentation.

The performance of Python 3.11 has improved by nearly 64%!

#According to the regulations set by the development team, the official version is expected to be released in October 2022.

A curious netizen tested it on his own virtual machine. He installed Python 3.10 and 3.11 in separate Docker containers and looked at their comparison in a set of benchmark tests.

The pyperformance package is used to complete this work. This package will help developers complete the heavy benchmark testing work.

Summary data, based on the average value, Python 3.11 is 14% faster than Python 3.10. The new 3.11 version is slightly slower on some benchmarks, but is 64% faster on most benchmarks.

The following are benchmark tests run on an M1 Pro MacBook Pro 16 with a 10-core CPU. Each Python version is installed in Docker, which uses 5 logical CPU cores.

The following are the running data of different packages:

The performance of Python 3.11 has improved by nearly 64%!

Currently, the official version of Python 3.11 has not been officially released, and we need to wait for a complete The stable version is currently testing only a candidate version. Perhaps the gap between the two will be wider after the official version is released.

Related reports: Speed ​​up by 25%! CPython 3.11 is coming

Written by Luo Qiqi, produced by | OSC Open Source Community (ID: oschina2013)

After retiring and coming back to join Microsoft’s Faster CPython team, Guido van Rossum, the father of Python, made harsh words at the 2021 Python Language Summit, saying that the team will achieve at least 1x speedup in version 3.11 of Python.

The performance of Python 3.11 has improved by nearly 64%!

#At this year’s Python Language Summit, Guido and team partner Mark Shannon reported the latest progress: compared with version 3.10, the speed of CPython 3.11 is 10 - Between 60%, depending on conditions such as code size and work area. CPython 3.11 is on average 25% faster than CPython 3.10 when compiled with GCC on Ubuntu Linux as measured using the pyperformance benchmark suite.

The performance of Python 3.11 has improved by nearly 64%!

The performance improvements of CPython 3.11 are mainly focused on faster startup and faster runtime. Most of these optimizations come from PEP 659: Adaptive Interpreter , its operating idea is somewhat similar to JIT, both of which identify hot codes, but the working scope of the adaptive interpreter cannot be separated from the bytecode. The work on the PEP 659 proposal is now almost complete, but dynamic optimization of for loops and binary operations still needs to be completed.

While speeding up by 25%, Python 3.11 still has some areas for improvement. For example, the memory consumption of Python in 3.11 is basically the same as that in 3.10.

In addition, we need to pay attention to the issue of C extensions: CPython’s simple interface with C is the main advantage, but the incompatibility with C extensions is a major drawback. The optimization work done by the Faster CPython team in CPython 3.11 has largely ignored the issue of extension modules. In this regard, team leader Shannon said that the team is exploring the possibility of exposing low-level function APIs to virtual machines to Reduce Python code and C code as much as possible.

As for the much-anticipated JIT compiler, Shannon said that the first step to implement JIT is to implement a tracing interpreter, but there are currently too many projects that need attention and the work of introducing a JIT compiler There is still some way to go, "it may not arrive until 3.13 at the earliest." (By the way, Shannon has always been skeptical about whether CPython really needs to introduce JIT.)

Interestingly, yesterday we reported on developer Sam Gross's new proposal: completely remove CPython interpretation GIL - Global Interpreter Lock. This proposal and the work of the Faster CPython team will speed up multi-threaded Python code in completely different ways, but the two may create some conflicts. After all, a large part of the optimizations that Faster CPython has implemented are based on the premise that the GIL still exists.

Note: At last year's core developer sprint meeting, the core developers conducted an in-depth discussion on the nogil project with Sam Gross and answered many questions that everyone was more concerned about. For specific meeting minutes, please view this article - Python Official Seminar: Is it really feasible to completely remove the GIL?

The above is the detailed content of The performance of Python 3.11 has improved by nearly 64%!. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:51cto.com. If there is any infringement, please contact admin@php.cn delete