šŸ Python 3.11.2: The Trick For 11% Speedup

Tom Smykowski
4 min readFeb 9, 2023

Among 60 fixes, developers maintain a 2 year old, brilliant performance improvement people donā€™t know about

Python 3.11.2 was released on February 7 and announced on February 9, 2023. It is a minor release, so why bother? I have spent some time to find some interesting things in this release, and one is a diamond! Letā€™s dig in!

šŸŖ² Proper Error Line

When a continue or break statement were placed outside the loop, Python reported the error line as -1. For example like here:

The bug was fixed by Dong-hee Na, and if you look at the original proposal it was done with four lines of code that preserve the original line number to display it properly.

Four lines is little, but the time to find the right placesā€¦

Read To The End For a Bonus!

šŸ’Ž A Fix Around A Brilliant And Unknown Up To 11% Performance Improvement

That one is pretty interesting. Two years ago Python developers introduced an improvement that increased the performance by up to 11%.

--

--

Tom Smykowski

Software Engineer & Tech Editor. Top 2% on StackOverflow, 3mil views on Quora. Won Shattered Pixel Dungeon.