Skip to content

Conversation

tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Apr 3, 2025

For context: #130415 (comment)

I did run make regen-cases and made sure that the test failed before making the change in optimizer_bytecodes.c :)

tomasr8 added 2 commits April 3, 2025 20:08
instruction after _CONTAINS_OP_SET by setting
the return type to bool.
Comment on lines +1616 to +1622
x = 0
s = {1, 2, 3}
for _ in range(n):
a = 2
in_set = a in s
if in_set:
x += 1
Copy link
Member Author

Choose a reason for hiding this comment

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

We might be able to simplify this further, I wasn't sure how much the peepholer would optimize out if I used e.g. 2 in s directly.

Copy link
Member

Choose a reason for hiding this comment

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

2 in s would have been fine, but this works well too!

@tomasr8 tomasr8 requested a review from brandtbucher April 3, 2025 21:10
@brandtbucher brandtbucher self-assigned this Apr 4, 2025
@brandtbucher brandtbucher merged commit 85bc489 into python:main Apr 5, 2025
62 checks passed
@tomasr8 tomasr8 deleted the jit-contains-op-set-narrow branch April 6, 2025 06:11
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
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.

3 participants