gh-150165: Clarify membership test semantics for hash-based containers and object identity#150166
Closed
KRRT7 wants to merge 1 commit into
Closed
gh-150165: Clarify membership test semantics for hash-based containers and object identity#150166KRRT7 wants to merge 1 commit into
KRRT7 wants to merge 1 commit into
Conversation
…tainers and object identity Split the membership test equivalence in §6.10.2 to distinguish sequence types (linear scan) from hash-based containers (hash lookup). Add a note acknowledging that the x is e check has observable consequences for NaN and state-dependent __eq__, and that object identity is unspecified for non-literal expressions. Also add a clarifying sentence in §6.2.3.1 noting that non-literal expressions make no identity guarantees.
|
The following commit authors need to sign the Contributor License Agreement: |
Documentation build overview
|
Member
|
Closing because the DPO thread does not have support from core devs yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed on discuss.python.org.
Changes
§6.10.2 Membership test operations:
§6.2.3.1 Literals and object identity:
Motivation
This came from a real bug: Nuitka/Nuitka#3889. Nuitka's constant blob cached ``float('nan')`` as a singleton, making ``nan2 in {nan1}`` return ``True`` instead of ``False``. Both were spec-compliant because the spec doesn't address whether calls return the same object — that ambiguity is what this PR addresses.
Related issues