Skip to content

PEP 661 -- Sentinel Values #258

Closed
Closed

Description

@taleinat

Please consider PEP 661 -- Sentinel Values
https://peps.python.org/pep-0661/

  • The PEP has been discussed in threads listed in its Post-History header
  • The PEP was announced on Discuss (link in Post-History)
  • The PEP includes all relevant Suggested Sections
  • The PEP includes endorsements from the projects/groups/people it helps
  • The PEP has a CODEOWNERS entry

Activity

  1. JelleZijlstra commented on Oct 14, 2024

    @JelleZijlstra
    Member

    Since this PEP proposes a change to the type system (an extension of the values allowed in Literal[]), the Typing Council is also looking at it. We'll discuss internally and share our opinion here if the Steering Council thinks it's helpful.

  2. encukou commented on Oct 15, 2024

    @encukou
    Member

    Note that there is some more discussion on Discourse, and the PEP might need to be changed.

  3. JelleZijlstra commented on Oct 16, 2024

    @JelleZijlstra
    Member

    On behalf of the Typing Council:

    The PEP currently proposes to use Literal[SentinelName] as the type annotation to describe the type of a sentinel object. We prefer to support SentinelName directly without the need to wrap it in a Literal . This would require the sentinel base class to supply a __or__ method to support unions, which would be straightforward. The most common sentinel value used in Python is None, and it is special-cased in the type system to not require Literal[None] in a type annotation. Since type checkers (both static and runtime) will already need to special-case sentinels, we wouldn’t gain any simplicity by forcing users to wrap sentinels in Literal[].

    A suggestion came up to allow both forms in type annotations, Literal[SentinelName] and SentinelName. We prefer to keep only the latter so we don’t introduce redundant ways to describe the same type.

    (Note from me personally: The change we're recommending here aligns with something Tal already said he was planning to change in the PEP, leading to Petr's message above.)

  4. taleinat commented on Oct 18, 2024

    @taleinat
    Author

    Thank you @JelleZijlstra and members of the Typing Council! Your opinions and feedback are greatly appreciated.

    I now agree that SentinelName is preferable to Literal[SentinelName]. I greatly prefer only SentinelName rather than both options.

  5. taleinat commented on Oct 25, 2024

    @taleinat
    Author

    Please note that the PEP has been amended to reflect the changes to typing as described by @JelleZijlstra above.

  6. Yhg1s commented on Oct 25, 2024

    @Yhg1s
    Member

    FYI, the current SC decided to leave this PEP for the next SC to decide, given that SC elections are very soon (https://discuss.python.org/t/steering-council-nominations-will-open-november-7th-2024).

  7. taleinat commented on Jan 26, 2025

    @taleinat
    Author

    I've created a PR with suggested post-submission changes to the PEP proposal.
    python/peps#4232

    I understand that the SC has recently begun reviewing this proposal. If possible, please consider the proposal to include these changes.

  8. taleinat commented on Jan 26, 2025

    @taleinat
    Author

    Also, please note that the current proposal suggests adding a new stdlib module, "sentinellib". It has been suggested to add a new "sentinel" builtin, instead, or to add this to the "typing" module; I consider all of these to be valid options.

  9. gpshead commented on Feb 6, 2025

    @gpshead
    Member

    SC review status: still on our radar, we're catching up on the latest in the Discuss thread before we can make any decisions.

  10. warsaw commented on Mar 20, 2025

    @warsaw
    Member

    The SC is waiting for a response on our offer of office hours to @taleinat

    Until then we are in a holding pattern for PEP 661.

  11. warsaw commented on Apr 10, 2025

    @warsaw
    Member

    The SC has decided to defer PEP 661. I'm going to close this ticket, but please do consider reopening this for Python 3.15.

  12. JelleZijlstra commented on Apr 21, 2026

    @JelleZijlstra
    Member

    Please (again) consider PEP 661, Sentinel Values. I know there's little time left for Python 3.15, but I hope we can still make it.

    I just merged a PEP change to make sentinel a builtin instead of a new module and add a C API: python/peps#4923 . This change is now live at https://peps.python.org/pep-0661/ . I also have a draft implementation at python/cpython#148831 so that we can quickly merge the change if the SC decides to accept this change for Python 3.15.

  13. hugovk commented on Apr 24, 2026

    @hugovk
    Member
  14. JelleZijlstra commented on May 16, 2026

    @JelleZijlstra
    Member

    I'd like the Steering Council's approval for two changes to the PEP: add a repr= argument, and make the __module__ attribute writable.

  15. warsaw commented on May 19, 2026

    @warsaw
    Member

    Hi @JelleZijlstra - the @python/steering-council approves those changes. Thanks for making this feature great for 3.15!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PEPPython Enhancement Proposal

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions