Skip to content
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
PHDPedia PHDPedia PHDPedia
PHDPedia PHDPedia PHDPedia
  • Home
  • Sitemap
  • Home
  • Sitemap
Close

Search

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
Subscribe
Data Science & Statistics for Researchers

PEP 824 None-coalescing operators

By Lina Hope
October 8, 2026 6 Min Read
Comments Off on PEP 824 None-coalescing operators

The Python steering committee and the broader developer community are currently evaluating a significant evolution in the language’s syntax through PEP 824, which proposes the introduction of two new operators designed to streamline the handling of None values. Authored by Marc Mueller and sponsored by Python’s creator, Guido van Rossum, the proposal aims to integrate "None-coalescing" and "None-coalescing assignment" operators into the forthcoming Python 3.16 release. This development represents a renewed effort to address a long-standing criticism regarding Python’s verbosity when dealing with default values and optional types, a challenge that has persisted despite the language’s reputation for readability.

The core of the proposal involves the addition of the ?? operator (None-coalescing) and the ??= operator (None-coalescing assignment). These symbols are intended to act as specialized conditional tools that focus specifically on the existence of a value rather than its "truthiness." While Python developers have traditionally used the or operator to provide fallback values, that approach frequently fails when legitimate data—such as an empty string, the number zero, or an empty list—is treated as "falsy" and inadvertently replaced by a default. PEP 824 seeks to eliminate this ambiguity by creating a dedicated pathway for checking is None.

Technical Mechanics of the Proposed Operators

The primary operator introduced by the PEP is the ?? symbol. Under the proposed specification, an expression formatted as a ?? b would evaluate the left-hand side (a). If the result of that evaluation is not None, the operator returns that value immediately. If the result is None, the right-hand side (b) is evaluated and returned. This behavior is functionally equivalent to the expression _t if ((_t := a) is not None) else b, but without the syntactical overhead of assignment expressions or manual null-checking.

Complementing this is the ??= assignment operator. This is designed to facilitate "lazy" or conditional assignments. In many Python applications, particularly those involving configuration or data processing, a variable may be initialized as None and later assigned a default only if no other value has been provided. Currently, this requires a multi-line if statement. The proposed ??= operator would allow a developer to write target ??= value, which would only execute the assignment if target is currently None. This not only reduces the lines of code but also prevents the unnecessary evaluation of the right-hand side expression if the target already contains valid data.

Historical Context and the Legacy of PEP 505

The journey toward None-aware operators in Python is not a new one. The proposal finds its roots in PEP 505, which was first introduced over a decade ago. PEP 505 was significantly more ambitious, proposing not only coalescing operators but also None-aware member access (?.) and indexing (?[]). That proposal was eventually deferred due to concerns regarding "symbol soup"—the fear that adding too many punctuation-based operators would degrade Python’s characteristic clarity.

PEP 824 represents a more focused, modular approach to this evolution. By decoupling the coalescing operators from the member access operators (which are now handled separately under PEP 823), Mueller and van Rossum aim to provide a more digestible path for language evolution. This strategy mirrors the "gradual typing" philosophy that Python has successfully employed with its type-hinting system, allowing the community to debate and adopt specific features without the weight of an all-encompassing overhaul.

Comparative Landscape: Industry Standards

Python’s move toward coalescing operators is partly a response to the standards set by other modern programming languages. As software development has become increasingly focused on safety and the avoidance of "null pointer" style errors, many of Python’s contemporaries have already implemented similar features:

  • JavaScript/TypeScript: Introduced the ?? operator in ECMAScript 2020 to distinguish between null/undefined and falsy values like 0 or "".
  • C#: Has long utilized ?? and ??= for null-coalescing, becoming a staple of the .NET ecosystem.
  • Swift and Kotlin: Both languages treat null-safety as a first-class citizen, using the "Elvis operator" (?:) in Kotlin and ?? in Swift to handle optional types.
  • PHP: Adopted the ?? operator in version 7.0 and ??= in version 7.4.

The prevalence of these operators in other languages has created a "muscle memory" for developers who move between ecosystems. Proponents of PEP 824 argue that Python’s lack of these tools has become an unnecessary hurdle for developers who expect a modern language to provide concise idioms for common null-handling patterns.

Chronology of Development

The timeline for PEP 824 indicates an aggressive but structured path toward implementation in Python 3.16:

  • September 20, 2026: PEP 824 is officially created and drafted by Marc Mueller.
  • September 22, 2026: The proposal is posted to the Python Discourse for public discussion, initiating a period of intense community scrutiny.
  • Late 2026 – Early 2027: Refinement period where the steering committee evaluates feedback regarding operator precedence and AST (Abstract Syntax Tree) implementation.
  • Mid 2027: Final decision expected on whether to include the feature in the Python 3.16 alpha releases.

Addressing the "None Proliferation" Concern

One of the most significant points of contention within the Python community is the potential for these operators to encourage the overuse of None. Critics, including some long-time core developers, argue that making it "easier" to work with None might lead to lazy API designs where functions return None instead of raising appropriate exceptions or returning specialized sentinel objects.

The "None is not special enough" argument suggests that by giving None its own dedicated operators, the language is elevating a single type above others. However, Mueller counters this in the PEP by noting that None is already special in the Python ecosystem. It is the de facto standard for representing the absence of a value, and its ubiquity in function signatures (e.g., def func(arg=None):) necessitates a more efficient way to handle it. The proposal emphasizes that these operators are not meant to replace robust data validation but to clean up the "boilerplate" code that follows it.

Impact on Code Readability and Safety

From a journalistic and analytical perspective, the impact of PEP 824 on code safety cannot be overstated. One of the subtle dangers in current Python code is the "double evaluation" problem. Consider the following common pattern:

value = get_complex_data() if get_complex_data() is not None else default_value

In this scenario, get_complex_data() is called twice. If that function involves a database query, a network request, or a heavy calculation, this is highly inefficient. If the function has side effects, it is outright dangerous. While the "walrus operator" (:=) introduced in Python 3.8 solved this by allowing value if (value := get_complex_data()) is not None else default_value, many developers find that syntax clunky and difficult to read. The ?? operator solves this natively by caching the result of the left-hand side evaluation automatically.

Official Responses and Community Reaction

The sponsorship of Guido van Rossum provides PEP 824 with significant weight. As the "Benevolent Dictator for Life" emeritus, van Rossum’s support often signals that a proposal aligns with the long-term vision of the language. However, the Python Steering Committee remains an independent body, and early reactions on the Python Discourse threads show a divided community.

Proponents highlight the "elegance" of the new syntax. "It turns four lines of guard clauses into a single, readable line," noted one contributor. Conversely, traditionalists argue that Python’s strength lies in its use of English-like keywords (and, or, not) rather than "cryptic" symbols. This led to a rejected idea within the PEP to use a keyword like otherwise instead of ??. The authors rejected the keyword approach because otherwise= would be syntactically awkward and because ?? is already a recognized standard in the global programming community.

Broader Implications for the Python Ecosystem

If adopted, PEP 824 will likely trigger a wave of updates across major Python libraries. Frameworks like Django, FastAPI, and Pydantic, which deal heavily with optional data and configuration defaults, would be the primary beneficiaries. The ability to write settings.DEBUG ??= True or user_id = request.json.get("id") ?? guest_id would likely become the new standard for "Pythonic" code.

Furthermore, the implementation of these operators requires changes to Python’s internal machinery, including the parser and the bytecode compiler. The proposal includes a reference implementation that introduces a new Coalesce operator to the boolop nodes in Python’s AST. This ensures that the operators are not just "macro-like" replacements but are integrated deeply into the language’s execution flow, maintaining Python’s performance standards.

As the discussion continues, PEP 824 stands as a testament to Python’s ongoing identity crisis: the struggle to remain the "simple" language for beginners while providing the sophisticated tools required by professional engineers working on massive, complex codebases. Whether ?? becomes as fundamental as + or - remains to be seen, but the proposal has undeniably ignited one of the most important syntactical debates in the history of the language.

Tags:

coalescingData ScienceMachine LearningnoneoperatorsR ProgrammingStatistics
Author

Lina Hope

Follow Me
Other Articles
Previous

How to Choose the Right Agentic AI Framework for Production Systems in 2026

Next

A Chance to Solve Their Own Problems Rethinking School Improvement Through Collective Inquiry and Adaptive Systems

Recent Posts

The Nuances of "Flaunt" and "Flout": Disambiguating Commonly Confused Verbs for Precision in CommunicationBridging Algorithmic Design and Regulatory Standards in Enterprise AIZotero 9 Revolutionizes Research Workflow with Read Aloud, Enhanced Annotation, and Performance UpgradesGarmin’s October Prime Day Deals: Extended Savings on Top Fitness Trackers
The Nuances of "Flaunt" and "Flout": Disambiguating Commonly Confused Verbs for Precision in CommunicationBridging Algorithmic Design and Regulatory Standards in Enterprise AIZotero 9 Revolutionizes Research Workflow with Read Aloud, Enhanced Annotation, and Performance UpgradesGarmin’s October Prime Day Deals: Extended Savings on Top Fitness Trackers
  • The Nuances of "Flaunt" and "Flout": Disambiguating Commonly Confused Verbs for Precision in Communication
  • Bridging Algorithmic Design and Regulatory Standards in Enterprise AI
  • Zotero 9 Revolutionizes Research Workflow with Read Aloud, Enhanced Annotation, and Performance Upgrades
  • Garmin’s October Prime Day Deals: Extended Savings on Top Fitness Trackers
  • Highlights from day 7 of National Science Week’s 9-day week

Archives

  • October 2026
  • September 2026
  • August 2026
  • July 2026
  • May 2026
  • April 2026

Categories

  • Academic Productivity & Tools
  • Academic Publishing & Open Access
  • Data Science & Statistics for Researchers
  • Funding, Grants & Fellowships
  • Higher Education News
  • Humanities & Social Sciences Research
  • Pedagogy & Teaching in Higher Ed
  • PhD Life & Mental Health
  • Post-PhD Careers & Alt-Ac
  • Research Methods & Methodology
  • Science Communication (SciComm)
  • Thesis & Academic Writing
Copyright 2026 — PHDPedia. All rights reserved. Blogsy WordPress Theme