Skip to content

gh-148083: Constant-fold _CONTAINS_OP_SET for frozenset#148084

Merged
corona10 merged 2 commits intopython:mainfrom
corona10:gh-148083
Apr 4, 2026
Merged

gh-148083: Constant-fold _CONTAINS_OP_SET for frozenset#148084
corona10 merged 2 commits intopython:mainfrom
corona10:gh-148083

Conversation

@corona10
Copy link
Copy Markdown
Member

@corona10 corona10 commented Apr 4, 2026

@corona10
Copy link
Copy Markdown
Member Author

corona10 commented Apr 4, 2026

AS-IS

['_START_EXECUTOR', '_MAKE_WARM', '_SET_IP', '_CHECK_PERIODIC', '_CHECK_VALIDITY', '_ITER_CHECK_RANGE', '_GUARD_NOT_EXHAUSTED_RANGE', '_ITER_NEXT_RANGE', '_SET_IP', '_SWAP_FAST_2', '_SPILL_OR_RELOAD', '_POP_TOP', '_CHECK_VALIDITY', '_LOAD_CONST_INLINE_BORROW', '_GUARD_GLOBALS_VERSION', '_LOAD_CONST_INLINE', '_SET_IP', '_CONTAINS_OP_SET', '_SPILL_OR_RELOAD', '_POP_TOP', '_POP_TOP_NOP', '_CHECK_VALIDITY', '_GUARD_BIT_IS_SET_POP_5', '_LOAD_FAST_BORROW_1', '_LOAD_CONST_INLINE_BORROW', '_GUARD_NOS_INT', '_BINARY_OP_ADD_INT', '_POP_TOP_NOP', '_POP_TOP_NOP', '_SWAP_FAST_1', '_POP_TOP_INT', '_JUMP_TO_TOP', '_DEOPT', '_ERROR_POP_N', '_DEOPT', '_EXIT_TRACE', '_EXIT_TRACE', '_ERROR_POP_N', '_DEOPT', '_DEOPT', '_ERROR_POP_N', '_DEOPT', '_EXIT_TRACE', '_EXIT_TRACE']

TO-BE

['_START_EXECUTOR', '_MAKE_WARM', '_SET_IP', '_CHECK_PERIODIC', '_CHECK_VALIDITY', '_ITER_CHECK_RANGE', '_GUARD_NOT_EXHAUSTED_RANGE', '_ITER_NEXT_RANGE', '_SET_IP', '_SWAP_FAST_2', '_SPILL_OR_RELOAD', '_POP_TOP', '_CHECK_VALIDITY', '_LOAD_CONST_INLINE_BORROW', '_GUARD_GLOBALS_VERSION', '_LOAD_CONST_INLINE', '_SET_IP', '_INSERT_2_LOAD_CONST_INLINE_BORROW', '_SPILL_OR_RELOAD', '_POP_TOP', '_POP_TOP_NOP', '_CHECK_VALIDITY', '_SET_IP', '_SPILL_OR_RELOAD', '_POP_TOP', '_CHECK_VALIDITY', '_LOAD_FAST_BORROW_1', '_LOAD_CONST_INLINE_BORROW', '_GUARD_NOS_INT', '_BINARY_OP_ADD_INT', '_POP_TOP_NOP', '_POP_TOP_NOP', '_SWAP_FAST_1', '_POP_TOP_INT', '_JUMP_TO_TOP', '_DEOPT', '_ERROR_POP_N', '_DEOPT', '_EXIT_TRACE', '_EXIT_TRACE', '_ERROR_POP_N', '_DEOPT', '_DEOPT', '_DEOPT', '_DEOPT', '_EXIT_TRACE']

@corona10 corona10 enabled auto-merge (squash) April 4, 2026 12:17
@corona10 corona10 merged commit 289f19a into python:main Apr 4, 2026
74 of 76 checks passed
(typ == &PyBool_Type) ||
(typ == &PyFrozenDict_Type);
(typ == &PyFrozenDict_Type) ||
(typ == &PyFrozenSet_Type);
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.

Ah wait this isnt really safe for the case of frozenset IN frozenset

Basically it's only safe if the LHS is a non-container safe type with pure hash function, and the RHS is frozenset

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.

So you need to add a check that says LHS != Frozenset/FrozenDict type.

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.

Same for frozendict btw.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will send a new PR for this :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants