Python 3.11, is about to get even faster!

thumbnail

" Let's Learn Python ", select the " Star " public account

Super invincible dry goods, delivered as soon as possible! ! !

Hello everyone, I'm a rookie.

As an extremely popular programming language, Python has many advantages, such as: easy to learn, versatile, and has thousands of useful libraries for data science. But at the same time, Python has been criticized for being too slow.

At the PyCon US 2021 conference last year, Guido van Rossum, the father of Python, once said: In Python 3.11 in 2022, the speed of Python will be increased by 2 times, and within 4 years, the speed will be increased by 5 times to solve other programming such as Python and C++ The key disadvantage of language compared to speed.

Today, too slow is about to change in Python 3.11. It is currently in the first beta phase of its preview release (version 3.11.0b1) ahead of a stable release later this year.

CPython 3.11 is 1.25 times faster than 3.10

At the recent PyCon US 2022 conference, Core Python (CPython) developer Mark Shannon shared details on accelerating Python projects, and the developers also showed progress towards the goal of running Python code in the browser.

Last year, Microsoft funded a Python Software Foundation (PSF) project, the "Shannon Plan," led by Python creators Guido van Rossum and Mark Shannon, which promised to make it 2x faster in this year's Python 3.11. Its vision is to push Python towards the performance of C.

Microsoft hired van Rossum in 2020 and gave him the freedom to choose any project. At last year's PyCon US 2021 conference, he said he "chooses to go back to my roots" and will work on addressing Python's famous performance deficit

Performance may not be the top priority for Python, as machine learning and data science adoption benefits from TensorFlow, NumPy, Pandas, and more platforms like AWS' Boto3 SDK for Python. These platforms are downloaded tens of millions of times a month and used in environments that are often not limited by hardware.

The Faster CPython project (GitHub address: https://github.com/faster-cpython/ideas/blob/main/main-vs-310.rst ) provides some performance updates about CPython 3.11 over the past year. Ahead of the PyCon US 2022 conference, the project announced more results: a comparison of the 3.11 beta preview and 3.10 on dozens of performance metrics showed that 3.11.0b1 was 1.25 times faster than 3.10 overall .

New bytecode interpreter makes error handling more efficient

Shannon is realistic about the project's ability to improve Python performance, but he believes the improvements could expand Python's viable uses to more virtual machines. He wrote last year in Python Enhancement Proposal (PEP) 659: "Python is widely considered to be slow.

While Python will never match the performance of lower-level languages ​​like C, Fortran or even Java, we expect it to rival fast implementations of scripting languages ​​like Java's V8 or Lua's LuaJIT. Specifically, we hope to achieve these performance goals with CPython to benefit all Python users, including those who cannot use PyPy or other alternative virtual machines. "

The key approach detailed in PEP 659 is: "A specialized, adaptive interpreter, but which aggressively specializes code in a very small area and is able to quickly and inexpensively accommodate faulty specializations. "

As mentioned above, optimization of virtual machines is "expensive" and often requires a long "warm-up" time. To avoid this time overhead, the virtual machine should speculate that "specialization is reasonable even after a function has been executed several times". Therefore, the interpreter needs to be optimized and de-optimized continuously and very cheaply.

This should result in a faster CPython interpreter that can trace individual bytecodes during program execution. According to the Python Software Foundation (PSF), work on the new interpreter is almost complete, but dynamic specialization of loops and binary operations still needs to be done.

Also, the memory consumption of 3.11 has not changed compared to 3.10.

CPython JIT compiler coming soon

Regarding the issue of just-in-time (JIT) compilers for Python performance, according to the Python Software Foundation (PSF) reporting on the event, Shannon believes that this is not a priority and may not be implemented until Python 3.13 at the earliest.

Additionally, Anaconda, makers of the Anaconda Python distribution for data science, is supporting Project Pyston, an implementation of Python that promises speed improvements over Python.

One of Anaconda's earlier efforts to speed up Python was the Numba project, an LLVM-based CPython JIT compiler that accelerated Python numerical functions running on CPUs or GPUs, but did not optimize entire programs or solve more complex problems. Extensive Python use cases. The other is PyPy, which is an implementation of CPython with a JIT compiler for faster performance.

According to the implementation plan of the Faster CPython project (GitHub address: https://github.com/markshannon/faster-cpython/blob/master/plan.md), CPython 3.12 may get a "simple JIT compiler for small areas" ", using a relatively simple, fast compiler to compile specialized code for small areas at runtime; while CPython 3.13 will expand the compilation area, enhancing the compiler to generate superior machine code .

Finally, what do you think of the above Faster CPython project's approach to speeding up Python? Welcome to leave a message in the comment area

CSDN reference link:

https://www.zdnet.com/article/programming-languages-python-is-slow-but-its-about-to-get-faster/

Getting Started: The most complete problem of zero-based learning Python | Zero-based learning Python for 8 months | Practical projects | Learning Python is this shortcut

Dry goods: Crawling Douban short reviews, the movie "Later Us" | Analysis of the best NBA player in 38 years | From much anticipation to word of mouth! Tang Detective 3 is disappointing | Laughing at the new Eternal Dragon Saber | Lantern riddle answering king | Using Python to make a large number of sketches of young ladies | Mission Impossible is so popular, I use machine learning to make a mini recommendation system movie

Fun: Pinball game | Jiugongge | Beautiful flower | Two hundred lines of Python "Running every day" game!

AI: A robot that can write poetry | Color pictures | Predict income | Mission Impossible is so popular, I use machine learning to make a mini recommendation system movie

Widget: Convert Pdf to Word, easily get tables and watermarks! | Save html web pages as pdf with one click! | Goodbye PDF extraction charges! | Create the strongest PDF converter with 90 lines of code, one-click conversion of word, PPT, excel, markdown, html | Make a DingTalk low-cost ticket reminder! |60 lines of code make a voice wallpaper switcher, watch Miss Sister every day! |

The year's hottest copy

  • 1). Shit! Convert Pdf to Word easily with Python!
  • 2). Learning Python is really fragrant! I made a website with 100 lines of code, helped people PS travel pictures, and earned a chicken leg to eat
  • 3). The first broadcast has exceeded 100 million, and it has become popular all over the Internet. I analyzed "Sister Riding the Wind and Waves" and found these secrets
  • 4). 80 lines of code! Use Python to make a Doraemon clone
  • 5). 20 python codes you must master, short and powerful, infinitely useful
  • 6). A collection of 30 Python weird tricks
  • 7). The 80-page "Rookie Learning Python Selected Dry Goods.pdf" that I summarized are all dry goods
  • 8). Goodbye Python! I'm going to learn Go! 2500 words in-depth analysis!
  • 9). Discover a licking dog benefit! This Python crawler artifact is so cool, it automatically downloads pictures of girls
Latest Programming News and Information | GeekBar

Related Posts