Skip to content

Twice to the Steering Council

Edit source

Rejected as PEP 690, accepted as PEP 810.

Part 7 of 7ofOpening Boxes
  1. 1The Forbidden Layer
  2. 2How to Emulate a 6802
  3. 3Redraw Only What Changed
  4. 4CSS That Computes
  5. 5A Search Engine from Scratch
  6. 6The Large, Black Ball
  7. 7Twice to the Steering Council

The sequel to The Large, Black Ball: what happened when I tried to give lazy imports to the whole language.

The previous article ended with PEP 690, the proposal Carl Meyer and I wrote to give lazy imports to Python itself. This is what happened next. The language said no, in December 2022. Then it said yes, in November 2025, to a different proposal that kept the idea and discarded the implementation detail I loved most. The feature is slated for Python 3.15.

It took knocking twice. Here is what changed between the knocks.

PEP 690 proposed lazy imports as a global switch. You would flip it on for your whole application, with a -L interpreter flag or an importlib.set_lazy_imports() call, and from that point every top-level import in the program became lazy: deferred until the imported name was first used. Imports inside try, except, or with blocks stayed eager (so import errors could be handled), star imports stayed eager (you cannot defer what you cannot enumerate), and anything inside a function or class was never “top level” to begin with.

The implementation was the dict-internals trick from the last article, written down formally. When a lazy import ran, the name went straight into the module namespace dictionary, but its value was an internal lazy import object holding the metadata to run the import later. A new flag on the dict’s keys, dk_lazy_imports in PyDictKeysObject, marked dictionaries that might contain one. Every dictionary lookup checked whether the value it was about to return was a lazy object, and if so, resolved it on the spot: run the import, replace the placeholder with the real value, return the real value. The laziness lived inside the dict, so it was automatic and invisible everywhere a name was ever read.

That is an elegant trick. It is also exactly what got the proposal into trouble.

The Steering Council rejected PEP 690 in December 2022. I will not pretend it did not sting. But the reason was honest, and with a few years of distance, correct.

A global switch splits the world into two Pythons. In one, imports are eager and have side effects exactly when you wrote them. In the other, they are lazy and those side effects happen later, or never. Every library would now have to work, and be tested, under both. The Council’s own words:

A world in which Python only supported imports behaving in a lazy manner would likely be great. But we cannot rewrite history and make that happen.

The key thing I missed in the moment, and got later: they had not rejected the idea. They had rejected the global switch. Laziness imposed invisibly on the whole ecosystem was the problem. Laziness you asked for, explicitly, was never on trial.

So we did it again, properly this time. With Pablo Galindo Salgado leading and a group of people I deeply respect, I helped author PEP 810. Instead of a mode that makes everything lazy, an explicit word you write yourself:

lazy import json
lazy from json import dumps

You opt in, per import, in the open. A reader sees lazy and knows exactly what was deferred. There is still a global flag and a __lazy_modules__ declaration for teams migrating a large codebase, and a sys.set_lazy_imports_filter() escape hatch for fine-grained control, but the heart of the proposal is the explicit keyword. It is the same idea the Council blessed in spirit, with the action-at-a-distance removed.

Here is the twist I did not see coming, and the reason this is its own article rather than a footnote.

PEP 810 deliberately does not touch the dictionary internals. The thing I was proudest of in the original implementation, the lazy object living inside the dict and resolving on lookup, is explicitly listed in PEP 810’s Rejected Ideas. The reasoning is sound, and it is a little humbling to read:

The dictionary is the foundational data structure in Python. […] Adding any kind of hook or special behavior to dicts to support lazy imports would: Prevent critical interpreter optimizations including future JIT compilation. Add complexity to a data structure that must remain simple and fast. Affect every part of Python, not just import behavior. Violate separation of concerns – the hash table shouldn’t know about the import system.

Instead, PEP 810 uses a LazyImportType proxy object. A lazy import binds the name to a proxy; the first time the name resolves, the proxy is replaced by the real value. No hook in the dict lookup path, so the JIT and every future dict optimization stay unobstructed. The PEP even works through why the proxy has to be a real replaceable object rather than something transformed in place: lazy from foo import bar can bind bar to any object, a function, a class, a constant, so there is no single memory layout to mutate into. A uniform proxy is the only thing that works for both lazy import x and lazy from x import y.

PEP 690 put the lazy object inside the dict and was rejected as a global switch; PEP 810 uses an explicit lazy keyword and a LazyImportType proxy with no dict hooks, and was accepted

I think the proxy is the right call. The dict trick was clever, and clever in the wrong place is a liability when the wrong place is the hottest data structure in the language. The second attempt is better than the first precisely because it gave up my favorite part of the first.

Shipping a feature inside one company and standardizing it for everyone are different crafts. Inside Instagram I optimized for “make it work, invisibly, for our codebase.” For the language, the right objective was “make it explicit, optional, and impossible to impose on someone who did not ask.” The Steering Council was protecting millions of people from a switch they would not have chosen, and they were right to.

On November 3, 2025, the Steering Council accepted PEP 810. The idea I had on a locked-down oncall night, annoyed at a server’s startup time, the one the language turned down three years earlier, is going into the grammar of Python 3.15. Not because the first attempt was right. Because the second one was better, and because a roomful of people carried it the rest of the way.

It just took knocking twice.


Sources: PEP 690 (Lazy Imports), PEP 810 (Explicit Lazy Imports), and the engineering story behind them in The Large, Black Ball. PEP 810 was authored with Pablo Galindo Salgado and others; I am a co-author.