FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131798: JIT: Narrow the return type of `_CONTAINS_OP_SET` to bool by tomasr8 · Pull Request #132057 · python/cpython · GitHub

Repository navigation

gh-131798: JIT: Narrow the return type of _CONTAINS_OP_SET to bool - #132057

Merged
brandtbucher merged 3 commits into
python:mainfrom
tomasr8:jit-contains-op-set-narrow
Apr 5, 2025
Merged

brandtbucher merged 3 commits into
python:mainfrom
tomasr8:jit-contains-op-set-narrow

Conversation

tomasr8 commented Apr 3, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

tomasr8 requested a review from brandtbucher April 3, 2025 21:10
brandtbucher self-assigned this Apr 4, 2025
brandtbucher merged commit 85bc489 into python:main Apr 5, 2025
tomasr8 deleted the jit-contains-op-set-narrow branch April 6, 2025 06:11
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL