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.
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.

3 participants