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. 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.
More InformationPython 3.11 Performance Benchmarks Are Looking Fantastic Python multithreading without the GIL PEP 659 -- Specializing Adaptive Interpreter https://github.com/faster-cpython Related ArticlesGuido 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.
Comments
or email your comment to: comments@i-programmer.info <ASIN:1871962668> <ASIN:1871962749>
|
|||
Last Updated ( Wednesday, 06 July 2022 ) |