Skip to content

PEP 851: Add list.discard() - #5200

Merged
StanFromIreland merged 3 commits into
python:mainfrom
StanFromIreland:pep-851
Oct 27, 2026
Merged

StanFromIreland merged 3 commits into
python:mainfrom
StanFromIreland:pep-851

Conversation

@StanFromIreland

Copy link
Copy Markdown
Member

Basic requirements (all PEP Types)

  • Read and followed PEP 1 & PEP 12
  • File created from the latest PEP template
  • PEP has next available number, & set in filename (pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) and PEP header
    • Tip: find the next available number with pepotron — run uvx pepotron next (or pipx install pepotron then pep next)
  • Title clearly, accurately and concisely describes the content in 79 characters or less
  • Core dev/PEP editor listed as Author or Sponsor, and formally confirmed their approval
  • Author, Status (Draft), Type and Created headers filled out correctly
  • PEP-Delegate, Topic, Requires and Replaces headers completed if appropriate
  • Required sections included
    • Abstract (first section)
    • Copyright (last section; exact wording from template required)
  • Code is well-formatted (PEP 7/PEP 8) and is in code blocks, with the right lexer names if non-Python
  • PEP builds with no warnings, pre-commit checks pass and content displays as intended in the rendered HTML
  • Authors/sponsor added to .github/CODEOWNERS for the PEP

Standards Track requirements

  • PEP topic discussed in a suitable venue with general agreement that a PEP is appropriate
  • Suggested sections included (unless not applicable)
    • Motivation
    • Specification
    • Rationale
    • Backwards Compatibility
    • Security Implications -- N/A
    • How to Teach This
    • Reference Implementation
    • Rejected Ideas
    • Open Issues -- N/A
    • Acknowledgements -- N/A
    • Footnotes
    • Change History -- N/A
  • Python-Version set to valid (pre-beta) future Python version, if relevant
  • Any project stated in the PEP as supporting/endorsing/benefiting from the PEP formally confirmed such
  • [] Right before or after initial merging, PEP discussion thread created and linked to in Discussions-To and Post-History

@StanFromIreland
StanFromIreland requested a review from a team as a code owner October 27, 2026 08:58
@read-the-docs-community

read-the-docs-community Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 pep-previews | 🛠️ Build #35438876 | 📁 Comparing 52d855d against latest (362ca9d)

  🔍 Preview build  

4 files changed
+ pep-0851/index.html
± index.html
± numerical/index.html
± pep-0000/index.html

@Rosuav

Rosuav commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

LGTM. I assume the "guarantee" about set.discard refers only to sane objects, as it's possible to violate that straightforwardly if you're willing to do dumb stuff in __eq__. It's certainly an expectation, though honestly that's key to the meaning of sets rather than the meaning of discard().

@StanFromIreland

Copy link
Copy Markdown
Member Author

Thanks for the review!

I assume the "guarantee" about set.discard refers only to sane objects, as it's possible to violate that straightforwardly if you're willing to do dumb stuff in eq. It's certainly an expectation, though honestly that's key to the meaning of sets rather than the meaning of discard().

True, but the PEP is focusing on the usual case with a well-behaved __eq__.

@Rosuav

Rosuav commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

True, but the PEP is focusing on the usual case with a well-behaved __eq__.

Yeah that's what I figured. I don't know if we need a different word than "guarantee" that's restricted to normal objects that behave normally, but regardless, the point is just as valid.

@StanFromIreland

Copy link
Copy Markdown
Member Author

I've changed it to describe the outcome ("after s.discard(x) the test x not in s holds") rather than call it a guarantee.

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a "Security Implications" section with "None".

Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Comment thread peps/pep-0851.rst Resolved
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
@StanFromIreland
StanFromIreland merged commit f8c6294 into python:main Oct 27, 2026
5 checks passed
@StanFromIreland
StanFromIreland deleted the pep-851 branch October 27, 2026 10:48
@brianschubert brianschubert added the new-pep A new draft PEP submitted for initial review label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-pep A new draft PEP submitted for initial review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants