Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Nov 7, 2025

Avoid taking critical section if the object is an exact frozenset.

Copy link
Contributor

@eendebakpt eendebakpt left a comment

Choose a reason for hiding this comment

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

Looks good to me. Also see #132290, which also removes locks for set arguments to PySet_Contains.

@Carreau
Copy link
Contributor

Carreau commented Nov 7, 2025

Do you want to include a variation of my proposed test in testcapi/set.c ? With the proper Null checks and Pydecref of course. This will avoid regressions.

@kumaraditya303
Copy link
Contributor Author

Do you want to include a variation of my proposed test in testcapi/set.c ? With the proper Null checks and Pydecref of course. This will avoid regressions.

Would you like to propose a PR for that? That could be backported as well but since this PR is perf optimization it won't be backported.

@kumaraditya303 kumaraditya303 merged commit 7211a34 into python:main Nov 11, 2025
44 checks passed
@kumaraditya303 kumaraditya303 deleted the set-optimize branch November 11, 2025 14:32
Carreau pushed a commit to Carreau/cpython that referenced this pull request Nov 11, 2025
As discussed in pythongh-141183, the test suite did not
test that PySet_Contains does not convert unhashable key
into a frozenset.

This commit adds a regression test for this
behavior, to ensure that any behavior change is
caught by the test suite.
Carreau added a commit to Carreau/cpython that referenced this pull request Nov 11, 2025
As discussed in pythongh-141183, the test suite did not
test that PySet_Contains does not convert unhashable key
into a frozenset.

This commit adds a regression test for this
behavior, to ensure that any behavior change is
caught by the test suite.
Carreau added a commit to Carreau/cpython that referenced this pull request Nov 11, 2025
As discussed in pythongh-141183, the test suite did not
test that PySet_Contains does not convert unhashable key
into a frozenset.

This commit adds a regression test for this
behavior, to ensure that any behavior change is
caught by the test suite.
@Carreau
Copy link
Contributor

Carreau commented Nov 11, 2025

Done as #141411

Carreau added a commit to Carreau/cpython that referenced this pull request Nov 11, 2025
As discussed in pythongh-141183, the test suite did not
test that PySet_Contains does not convert unhashable key
into a frozenset.

This commit adds a regression test for this
behavior, to ensure that any behavior change is
caught by the test suite.
@nascheme nascheme added the needs backport to 3.14 bugs and security fixes label Nov 19, 2025
@miss-islington-app
Copy link

Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 19, 2025
…141183)

(cherry picked from commit 7211a34)

Co-authored-by: Kumar Aditya <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Nov 19, 2025

GH-141773 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Nov 19, 2025
nascheme pushed a commit that referenced this pull request Nov 20, 2025
… (gh-141773)

(cherry picked from commit 7211a34)

Co-authored-by: Kumar Aditya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants