This article is more than 1 year old

Guido van Rossum aiming to make CPython 2x faster in 3.11

'I got bored sitting at home while retired ... I chose to go back to my roots'

Language Summit Python creator Guido van Rossum this week told attendees at the Language Summit that he hopes to double performance in version 3.11.

The programming language is relatively slow in its default CPython implementation, though there are many ways to make it faster including performance-oriented alternatives like PyPy. Historically Van Rossum had seemed unconcerned about Python performance, favouring the simplicity of a compiler that is less well optimized.

Slides from the summit now posted [PDF] suggest a change of heart. "I got bored sitting at home while retired," he said. "I applied at Microsoft and got hired. I was given freedom to pick a project. I chose to go back to my roots. This is Microsoft's way of giving back to Python."

The project is a "small team funded by Microsoft," to include Python Core developer and Microsoft Senior Software Engineer Eric Snow, and Mark Shannon, research engineer at Semmle, which develops produces for code security analysis. Semmle has been part of GitHub since September 2019, so this is an all-Microsoft team, though Van Rossum noted it "might grow".

The project has a GitHub repository which includes a fork of CPython as well as an issue tracker for ideas and tools for analysing performance. According to Van Rossum, there will be "no long-lived forks/branches, no surprise 6,000 line pull requests," and everything will be open source.

Shannon has worked on Python performance for some time, with previous projects HotPy and HotPy (2) for a just-in-time compiler for CPython.

He has his own Faster CPython repository where he wrote that "we want to speed up CPython by a factor of 5 over the next four releases."

He noted though that some platforms, such as Apple's iOS, do not allow "runtime code generation," but believes that even in these cases a doubling of speed should be possible.

Although Shannon envisages a JIT compiler eventually, this would not come until Python 3.12 in his plan. The changes for Python 3.11 would be based on "lots of tweaks" such as better memory layout, improved performance for small integers, faster calls and returns, and zero overhead exception handling.

There are number of constraints, as Van Rossum noted in his talk, including not breaking stable ABI (Application Binary Interface) compatibility, keeping code compatible, and not causing slowdowns in edge cases. He said that many things can be safely changed though, including the Python bytecode, stack frame layout, compiler and interpreter. The stack frame layout describes how the data which defines a function is positioned in memory.

The notes by Van Rossum seem to match well with Shannon's existing ideas. "There's machine code generation in our future," he said, and like Shannon, refers to 5x speedup as a long-term goal, even though "we'll have to be creative."

Python 3.10, currently in beta, is scheduled for release in October this year. The release schedule is roughly annual, so we might expect 3.11 in October 2022. ®

More about


Send us news

Other stories you might like