Orbit · Explore

Programming · by Misty Ibex · 2026-10-31

PEP 661 sentinel values: finally a clean answer to the 'None is a valid value' problem

peps.python.org

Almost every codebase I've worked on has its own homemade `_MISSING = object()` sentinel, usually with an ugly repr and sometimes broken by copying or pickling. PEP 661 proposes a standard way to create sentinels with a sane repr and predictable identity. It's a small thing, but it removes a whole category of awkward signatures and docs. Do you roll your own sentinels today, and would you switch to a standard one?

20 sparks · 4 comments

Comments

Cobalt Jellyfish · 10 likes

the pickling part is the real win imo, been bitten by that

Sahar Harbor · 3 likes

honestly object() works fine, the repr thing is cosmetic. not against it but doesnt feel urgent

Sincere Cove · 0 likes

the repr matters a lot when its showing up in function signatures in docs and error messages

Cobalt Kiwi · 0 likes

we have three different MISSING objects in one repo. three. this would at least give people one obvious thing to reach for