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 various instructions with `_POP_TOP` and `_POP_TWO` by savannahostrowski · Pull Request #137577 · python/cpython

Conversation

@savannahostrowski

@savannahostrowski savannahostrowski commented Aug 9, 2025 •
edited
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
  • Issue: Better constant narrowing in the JIT optimizer #130415

Sorry, something went wrong.

Uh oh!

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

All reactions
savannahostrowski added 8 commits July 25, 2025 21:27
@savannahostrowski
_COMPARE_OP and _CONTAINS_OP
b4b2106
@savannahostrowski
add pop_top
cc4b9ce
@savannahostrowski
progress
2d5f428
@savannahostrowski
Merge branch 'main' into poptimize
8e7023d
@savannahostrowski
POP TOP
e75ca80
@savannahostrowski
UNARY_NOT
3b37082
@savannahostrowski
UNARY_NEGATIVE
e7a1e7e
@savannahostrowski
UNARY_INVERT
f69228a
@savannahostrowski
savannahostrowski requested a review from brandtbucher August 9, 2025 02:35
@savannahostrowski
savannahostrowski requested review from Fidget-Spinner, markshannon and tomasr8 as code owners August 9, 2025 02:35
@bedevere-app bedevere-app Bot added the awaiting core review label Aug 9, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Aug 9, 2025
Constant evaluate/propagate pure ops automatically #132732
Closed
@savannahostrowski savannahostrowski changed the title GH-132732: Use pure op machinery to optimize various _POP_TOP and _POP_TWO relevant instructions GH-132732: Use pure op machinery to optimize various instructions with _POP_TOP and _POP_TWO Aug 9, 2025
savannahostrowski and others added 4 commits August 8, 2025 19:41
@savannahostrowski
Remove test
01a8e2a
@savannahostrowski
Merge branch 'main' into poptimize
443a924
@savannahostrowski
Add check for _
49bd7c9
@blurb-it
📜🤖 Added by blurb_it.
2ada46b
brandtbucher
brandtbucher requested changes Aug 9, 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 super cool! Just a quick run-through for now:

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2025-08-09-04-07-05.gh-issue-132732.8BiIVJ.rst Resolved

Uh oh!

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

Comment thread Python/optimizer_bytecodes.c Resolved

Uh oh!

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

Comment thread Python/optimizer_bytecodes.c Resolved

Uh oh!

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

Comment thread Python/optimizer_cases.c.h Resolved

Uh oh!

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

Comment thread Python/optimizer_cases.c.h 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.

Comment thread Python/optimizer_bytecodes.c Resolved

Uh oh!

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

Comment thread Lib/test/test_capi/test_opt.py Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting core review labels Aug 9, 2025
@bedevere-app

bedevere-app Bot commented Aug 9, 2025

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

savannahostrowski added 3 commits August 8, 2025 21:49
@savannahostrowski
Address PR comments
024690c
@savannahostrowski
Add back replace_op
7945c19
@savannahostrowski
Update cases
55d098f
Fidget-Spinner
Fidget-Spinner reviewed Aug 9, 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.

Very cool, just one nit.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/optimizer_bytecodes.c Resolved

Uh oh!

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

@savannahostrowski
Guard against booleans in unary_invert
4c614a0
Fidget-Spinner
Fidget-Spinner approved these changes Aug 11, 2025
View reviewed changes
@bedevere-app bedevere-app Bot removed the awaiting changes label Aug 11, 2025
@bedevere-app bedevere-app Bot added the awaiting merge label Aug 11, 2025
@savannahostrowski

savannahostrowski commented Aug 21, 2025

Copy link
Copy Markdown
Member Author

@brandtbucher Do you want to take another look at this?

All reactions

Sorry, something went wrong.

Uh oh!

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

brandtbucher
brandtbucher approved these changes Sep 15, 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.

Looks good! Just a few suggestions for comments and cleaning up the generated code.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/optimizer_bytecodes.c Resolved

Uh oh!

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

Comment thread Python/optimizer_bytecodes.c Resolved

Uh oh!

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

Comment thread Python/optimizer_cases.c.h Outdated
Comment on lines +205 to +211
if (sym_is_const(ctx, res)) {
PyObject *result = sym_get_const(ctx, res);
if (_Py_IsImmortal(result)) {
// Replace with _POP_TOP_LOAD_CONST_INLINE_BORROW since we have one input and an immortal result
REPLACE_OP(this_instr, _POP_TOP_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)result);
}
}

@brandtbucher brandtbucher Sep 15, 2025

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.

Still seeing weird indent here, maybe dedent the string in the cases generator?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Python/optimizer_cases.c.h Resolved

Uh oh!

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

savannahostrowski added 5 commits September 15, 2025 10:50
@savannahostrowski
Merge branch 'main' into poptimize
fc293dc
@savannahostrowski
Address PR comments
ef5b7c8
@savannahostrowski
Fix indentation
9cee967
@savannahostrowski
Fix indentation
b160d20
@savannahostrowski
Add newline
c6edbf9
brandtbucher
brandtbucher approved these changes Sep 15, 2025
View reviewed changes
@savannahostrowski
savannahostrowski merged commit 9c9a0f7 into python:main Sep 15, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@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
@tomasr8 tomasr8 Awaiting requested review from tomasr8 tomasr8 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.

3 participants

@savannahostrowski @Fidget-Spinner @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.