Michael A. White

A PEP (Python Enhancement Proposal) Proposal

October 1, 2026

I’ve been using Python for about 20 years but discovered it 10 years earlier and have launched one SaaS (Software-as-a-Service) where all the code written by me was in Python. I love the language and think it is the best interpreted programming language and good enough for any GUI-DB application. I greatly appreciate the advanced metaprogramming features such as metaclasses that make SQLAlchemy models and queries highly concise and declarative.

Python can be slow due to the need to support metaprogramming and other dynamic features such as metaclasses, dynamic attribute lookup, and the ability to set any attribute on any object. While creating different dialects of the same language is usually frowned upon in the programming language design community, I think it might be worthwhile for python to create a mode, triggered by an import statement or a “use fast” declaration similar to “use strict” in JavaScript, that tries to make Python faster.

The mode would do the following:

The way I see it, other than a few specialized libraries, there is very little need for most code to use these dynamic features of Python, and a significant performance improvement can be achieved by allowing some modules to indicate that they do not use them.

In addition, the mode can allow multi-line lambdas.

Furthermore, I believe any code that is fully type annotated (all functions and variables) with types other than Any (or an AnyExpensive type alias can be introduced) can probably be compiled ahead of time if written in this mode, resulting in a significant speed up if the interoperation with modules that support Python’s standard dynamic features can be figured out, which I assume it probably can.

While it is unusual to create different modes for different syntax features in a programming language, I believe it would be worth it in this case for Python, but I admit I haven’t tested it and don’t know how to implement it.