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.

pythonfast1

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.

pfsbanner

A second general complaint is that there is still no JIT (Just In Time) compiler for Python. Other languages, notably JavaScript, have benefited from the speedup a JIT produces, but the Python team is still being vague about any future effort to produce a JIT while considering other options.

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.

python3

More Information

Python 3.11 Performance Benchmarks Are Looking Fantastic

Python multithreading without the GIL

What’s New In Python 3.11

PEP 659 -- Specializing Adaptive Interpreter

https://github.com/faster-cpython

Related Articles

Guido And Microsoft Want To Make Python x2 Faster

Microsoft Now Visionary Sponsor Of Python

What Makes Python Great & Greater

Guido van Rossum Quits As Python BDFL 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


Apple Improves Developer Support
10/06/2022

Apple has announced a range of new tools and technologies at its annual Worldwide Developer Conference (WWDC), including making Xcode Cloud open to all members of the Apple Developer Program.



New Database Drivers for Oracle and PostgreSQL Released
16/06/2022

The PostgreSQL JDBC Team team has announced the release 42.4.0 of the JDBC driver for PostgreSQL. Meanwhile Oracle has released a Python-based driver for Oracle. Python and Java users rejoice!


More News

pythondata

 



 

Comments




or email your comment to: comments@i-programmer.info

<ASIN:1871962668>

<ASIN:187196265X>

 

Last Updated ( Wednesday, 08 June 2022 )