GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-132732: Use pure op machinery to optimize `COMPARE_OP_INT/FLOAT/STR` by savannahostrowski · Pull Request #137062 · python/cpython

Conversation

@savannahostrowski

@savannahostrowski savannahostrowski commented Jul 24, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Constant evaluate/propagate pure ops automatically #132732

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
savannahostrowski added 8 commits July 21, 2025 16:16
@savannahostrowski
In progress
2c046f1
@savannahostrowski
Merge branch 'main' into constant_compare
8341b8d
@savannahostrowski
Works for int
8723267
@savannahostrowski
Remove extraneous asserts
4c86003
@savannahostrowski
Add back deleted test
f5d2210
@savannahostrowski
Optimize compare_op_str and add test
db7f2e7
@savannahostrowski
Optimize compare_op_float, add tests and header
f537ca0
@savannahostrowski
uncomment
a87045d
@savannahostrowski
savannahostrowski requested a review from brandtbucher July 24, 2025 02:11
@savannahostrowski
savannahostrowski requested review from Fidget-Spinner, markshannon and tomasr8 as code owners July 24, 2025 02:11
@bedevere-app bedevere-app Bot added the awaiting core review label Jul 24, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Jul 24, 2025
Constant evaluate/propagate pure ops automatically #132732
Closed
blurb-it Bot and others added 5 commits July 24, 2025 02:14
@blurb-it
📜🤖 Added by blurb_it.
d06cf6c
@savannahostrowski
Merge branch 'main' into constant_compare
eafa153
@savannahostrowski
Merge branch 'main' into constant_compare
2cbc5a0
@savannahostrowski
Merge branch 'constant_compare' of https://github.com/savannahostrows…
4b50bc8
…ki/cpython into constant_compare
@savannahostrowski
Fix indent?
67e24a7
Fidget-Spinner
Fidget-Spinner approved these changes Jul 24, 2025
View reviewed changes

@Fidget-Spinner Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Awesome work! This LGTM, just a few nits for the comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

savannahostrowski reacted with rocket emoji
All reactions
  • 🚀 1 reaction
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2025-07-24-02-13-59.gh-issue-132732.p77xkb.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/cases_generator/optimizer_generator.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Jul 24, 2025
tomasr8
tomasr8 approved these changes Jul 24, 2025
View reviewed changes

@tomasr8 tomasr8 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM :) just one question: this also adds the _POP_TWO_LOAD_CONST_INLINE_BORROW optimization to other ops like _BINARY_OP_ADD_FLOAT and others. Is it worth to add tests for these ops as well?
Essentially something like test_compare_op_float_pop_two_load_const_inline_borrow but adapted for _BINARY_OP_ADD_FLOAT, etc.. This would mean adding quite a few tests so I'm not sure if it makes sense.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@savannahostrowski @Fidget-Spinner
Apply suggestions from code review
5b01de8
Co-authored-by: Ken Jin <[email protected]>
@Fidget-Spinner

Fidget-Spinner commented Jul 24, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Let's leave it open for a few more days in case someone else wants to leave any comments, then merge it!

savannahostrowski reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@savannahostrowski
Fix comment
34ff87d
brandtbucher
brandtbucher approved these changes Jul 24, 2025
View reviewed changes

@brandtbucher brandtbucher left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is great! I'd love to see it extended (later) to handle even more cases.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@savannahostrowski

savannahostrowski commented Jul 26, 2025

Copy link
Copy Markdown
Member Author

Chatted with Brandt and I think I'm going to land this PR as is. I plan to go back and do a pass to add more optimizations with _POP_TWO_LOAD_CONST_INLINE_BORROW, _POP_TOP_LOAD_CONST_INLINE_BORROW, etc. elsewhere.

Fidget-Spinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@savannahostrowski
savannahostrowski merged commit f7c380e into python:main Jul 26, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Jul 26, 2025
@savannahostrowski savannahostrowski mentioned this pull request Jul 26, 2025
Better constant narrowing in the JIT optimizer #130415
Closed
13 of 17 tasks
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@savannahostrowski @Fidget-Spinner @Agent-Hellboy
pythonGH-132732: Use pure op machinery to optimize `COMPARE_OP_INT/FL…
be20104
…OAT/STR` (python#137062)

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

Reviewers

@tomasr8 tomasr8 tomasr8 approved these changes
@Fidget-Spinner Fidget-Spinner Fidget-Spinner approved these changes
@brandtbucher brandtbucher brandtbucher approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@savannahostrowski @Fidget-Spinner @tomasr8 @brandtbucher
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.