Skip to content

gh-131798: Optimize _UNARY_NEGATIVE - #135223

Merged
Fidget-Spinner merged 10 commits into
python:mainfrom
noamcohen97:optimize-unary-negate
Jun 23, 2025
Merged

gh-131798: Optimize _UNARY_NEGATIVE#135223
Fidget-Spinner merged 10 commits into
python:mainfrom
noamcohen97:optimize-unary-negate

Conversation

@noamcohen97

@noamcohen97noamcohen97 commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

Comment threadPython/optimizer_bytecodes.c Outdated

@brandtbucherbrandtbucher left a comment

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.

Looks good, just some suggested improvements. Thanks!

Comment threadPython/optimizer_bytecodes.c Outdated
Comment threadPython/optimizer_bytecodes.c Outdated
@noamcohen97

Copy link
Copy Markdown
ContributorAuthor

Thanks for the review! @brandtbucher@Zheaoli

@brandtbucherbrandtbucher left a comment

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.

Awesome! Can you just fix the merge conflict in the test file?

@noamcohen97

Copy link
Copy Markdown
ContributorAuthor

Done!

@Fidget-Spinner

Copy link
Copy Markdown
Member

@noamcohen97 sorry it seems there's merge conflicts again from merging your other PR.

@noamcohen97

Copy link
Copy Markdown
ContributorAuthor

@Fidget-Spinner I should have seen this coming 😄

@Fidget-Spinner

Copy link
Copy Markdown
Member

@noamcohen97 sorry I forgot to merge this in time and seems there's conflicts again 🤦 . Could you please merge in main again? I'll make sure to remember to merge it soon this time.

@Fidget-SpinnerFidget-Spinner self-assigned this Jun 23, 2025
@noamcohen97
noamcohen97force-pushed the optimize-unary-negate branch from 72c83d8 to 517d7efCompareJune 23, 2025 18:47
@noamcohen97

Copy link
Copy Markdown
ContributorAuthor

@Fidget-Spinner seems like _UNARY_NEGATIVE already got optimized in #135668 without considering float value and non-compact integer values.
I suggest we replace the current implementation with this one. WDYT?

@Fidget-Spinner

Copy link
Copy Markdown
Member

@noamcohen97 sounds good. Just make sure to use compact ints. Thanks!

@Fidget-SpinnerFidget-Spinner left a comment

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.

Thanks!

@Fidget-Spinner
Fidget-Spinner merged commit bda1218 into python:mainJun 23, 2025
51 checks passed
@noamcohen97
noamcohen97 deleted the optimize-unary-negate branch June 23, 2025 19:42
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
Sign up for freeto 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.

5 participants

@noamcohen97@Fidget-Spinner@Zheaoli@tomasr8@brandtbucher