Python Speedup Proposals

The original "CPython" implementation is in some ways similar to Rebol/Red... though these days Ren-C is more aligned with the stackless Python implementation...which is also written in C, but distinct from CPython.

(But Ren-C's design overall is a lot less comparable to anything, due to the number of very "alien" ideas in it, but that I think are what gives it more notable properties.)

In any case, despite running an interpreter loop and doing kind-of-what-Rebol-does, they've committed themselves to doing some speedup proposals and apparently it's paying off:

A Team at Microsoft is Helping Make Python Faster - Python

Some of their proposals involve JIT-compiling things (which they know won't work on restrictive platforms like iOS). But they apparently have done a lot of tweaks besides that which have turned out beneficial. Because it's a C interpreter there might be something applicable to be learned by looking at their "Stage 1" and "Stage 2" changes.

Stage 1 -- Python 3.10

The key improvement for 3.10 will be an adaptive, specializing interpreter. The interpreter will adapt to types and values during execution, exploiting type stability in the program, without needing runtime code generation.

Stage 2 -- Python 3.11

This stage will make many improvements to the runtime and key objects. Stage two will be characterized by lots of "tweaks", rather than any "headline" improvement. The planned improvements include:

  • Improved performance for integers of less than one machine word.
  • Improved peformance for binary operators.
  • Faster calls and returns, through better handling of frames.
  • Better object memory layout and reduced memory management overhead.
  • Zero overhead exception handling.
  • Further enhancements to the interpreter
  • Other small enhancements.

Stage 3 -- Python 3.12 (requires runtime code generation)

Simple "JIT" compiler for small regions. Compile small regions of specialized code, using a relatively simple, fast compiler.

Stage 4 -- Python 3.13 (requires runtime code generation)

Extend regions for compilation. Enhance compiler to generate superior machine code.

1 Like