Oriel — AI & technology worth noticing, every day.

Much Ado About None: Sentinel Values in Python

Web page · https://florianwilhelm.info/2026/10/sentinel_values

First seen by Oriel on .

AI summary

The article explains how Python sentinel values remove None-related ambiguity and recommends Python 3.15’s built-in sentinel, standardized by PEP 661, over object() and Enum workarounds.

  • Sentinels sit outside valid value domains, distinguishing missing or unchanged data, explicit None values, and error outcomes without collisions.
  • Python already uses Ellipsis and NotImplemented, while Pydantic 2.14’s MISSING distinguishes explicit null from fields never sent.
  • MISSING = object() works at runtime but impairs static type narrowing; copying and pickling can also break identity checks.
  • Python 3.15’s sentinel enables None-like type narrowing, and typing_extensions offers a backport for older versions.
  • Type-checker support remains incomplete, so users should verify their checker before relying on the standardized feature.

#python #sentinel values #type checking #pep 661

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Points

Score reported by the source.

  • Hacker News: 73, latest observation ; +67 over observed period since

Comments

Comment count reported by the source.

  • Hacker News: 49, latest observation ; +49 over observed period since

Aliases

SourceExternal IDURL
Hacker News50297068https://florianwilhelm.info/2026/10/sentinel_values/ Read discussion