|Python 3.11 Goes Faster|
|Written by Mike James|
|Wednesday, 08 June 2022|
Python doesn't do a bad job of being fast given how sophisticated it is, but it seems it is about to do a whole lot better according to independent benchmarks. Version 3.11 incorporates many of the changes promised in the Faster CPython project.
Many programmers complain that Python is slow, and compared to C it is, but then compared to C nearly everything is.
Python offers you a high-level language with speed that makes it good enough for a lot of things. The problem is that Python just hasn't been improving much with each new version - but all this is about to change. We reported on the new effort to make it faster in mid 2021 and now we are starting to see some results.
The official documentation currently claims an improvment of 25% for 3.11 over 3.10. The testing site Phoronix has conductive an extensive test and reports that the currrent Python 3.11 beta was 45% faster than 3.10 and 48% faster than the older 3.8. This is impressive.
There are many reasons for the improvements, but the most important is described in PEP 659 - the specializing adaptive interpreter. This seems to be a way of converting the dynamic operations of Python by more specialized operations which don't allow things to change. This means we can have the best of both worlds - dynamic typing with the efficiency of static typing. It's not perfect and it's not always applicable.
There is no movement on the important issue of removing the GIL from Python. The Global Interpreter Lock or GIL restricts the Python interpreter to only running a single thread at a time, even when running on a multicore machine. This is one of the big disappointments for anyone wanting to speed things up. The GIL, even though it slows things down for advanced users, keeps things fast for the majority of programs which are single-threaded. The general feeling seems to be that removing the GIL is not acceptable if the result slows things down for single-threaded development. Sam Gross proved that it can be done by doing it.
Removing the GIL without slowing down single-threaded programs has been achieved - but only by introducing optimizations that have nothing to do with the GIL. The general worry is that, now that some of these improvements have been Incorporated into Python 3.11, the standard for removing the GIL has just moved. Now the task is to remove the GIL without slowing single-threaded programs down - but after they have been speeded up by the improvements that were introduced in an effort to remove the GIL.
More improvements are in the pipeline for 3.12. It is difficult to believe that there is much more to be gained - but we will see.
Python 3.11 is currently in beta and should be released in the final quarter of 2022.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Wednesday, 06 July 2022 )|