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-131798: JIT: Narrow the return type of _CALL_LEN to int by diegorusso · Pull Request #132940 · python/cpython

Conversation

@diegorusso

@diegorusso diegorusso commented Apr 25, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Reduce unnecessary guards whenever len() is called and used in arithmetic operations.

  • Issue: Better uop coverage in the JIT optimizer #131798

Sorry, something went wrong.

Uh oh!

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

All reactions
@diegorusso
pythongh-131798: JIT: Narrow the return type of _CALL_LEN to int
ee947e3
Reduce unnecessary guards whenever `len()` is called and used
in arithmetic operations.
@diegorusso
diegorusso requested a review from Fidget-Spinner as a code owner April 25, 2025 13:58
@bedevere-app bedevere-app Bot added the awaiting review label Apr 25, 2025
@diegorusso
diegorusso requested review from brandtbucher and removed request for Fidget-Spinner April 25, 2025 13:58
@bedevere-app bedevere-app Bot mentioned this pull request Apr 25, 2025
Better uop coverage in the JIT optimizer #131798
Open
@diegorusso
diegorusso requested a review from Fidget-Spinner April 25, 2025 14:34
Fidget-Spinner
Fidget-Spinner approved these changes Apr 25, 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.

Thanks!

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Apr 25, 2025
@Fidget-Spinner

Fidget-Spinner commented Apr 25, 2025

Copy link
Copy Markdown
Member

Windows JIT builds might've been broken by #132852. That PR did not trigger JIT CI.

All reactions

Sorry, something went wrong.

Uh oh!

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

tomasr8
tomasr8 reviewed Apr 25, 2025
View reviewed changes
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
Comment on lines +1916 to +1920
a = [1, 2, 3, 4]
for _ in range(n):
_ = len(a) - 1

_, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)

@tomasr8 tomasr8 Apr 25, 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.

I don't know if it's needed in this case, but for other tests there's normally a 'control' variable that checks that the result is still correct even with the optimization. Something like this:

Suggested change
a = [1, 2, 3, 4]
for _ in range(n):
_ = len(a) - 1
_, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
x = 0
a = [1, 2, 3, 4]
for _ in range(n):
_ = len(a) - 1
if _ == 3:
x += 1
_, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)

Sorry, something went wrong.

Uh oh!

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

All reactions

@diegorusso diegorusso Apr 25, 2025

Copy link
Copy Markdown
Contributor Author

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.

Good point, I'll do it.

Sorry, something went wrong.

Uh oh!

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

All reactions

@diegorusso diegorusso Apr 25, 2025

Copy link
Copy Markdown
Contributor Author

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.

OK the problem is if I add this, _GUARD_TOS_INT and _GUARD_NOS_INT are appearing in the uops list.

Sorry, something went wrong.

Uh oh!

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

All reactions

@Fidget-Spinner Fidget-Spinner Apr 25, 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.

Yeah we can't do it. x is from outside the loop (trace), so the first x += 1 has to have a guard somewhere.

Sorry, something went wrong.

Uh oh!

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

diegorusso and tomasr8 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@blurb-it
📜🤖 Added by blurb_it.
705bf8b
tekknolagi
tekknolagi reviewed Apr 25, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2025-04-25-14-56-45.gh-issue-131798.NpcKub.rst Resolved

Uh oh!

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

Fidget-Spinner and others added 2 commits April 26, 2025 01:48
@Fidget-Spinner
Merge branch 'main' into call-len
e4e6bbf
@diegorusso @tekknolagi
Update Misc/NEWS.d/next/Core_and_Builtins/2025-04-25-14-56-45.gh-issu…
a017e93
…e-131798.NpcKub.rst

Co-authored-by: Max Bernstein <[email protected]>
@Fidget-Spinner
Fidget-Spinner merged commit 4c20f46 into python:main Apr 25, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 25, 2025
@diegorusso
diegorusso deleted the call-len branch April 30, 2025 00:15
@tomasr8 tomasr8 mentioned this pull request May 1, 2025
Keep instruction definitions in bytecodes.c and optimizer_bytecodes.c in sync #133273
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tomasr8 tomasr8 tomasr8 left review comments
@Fidget-Spinner Fidget-Spinner Fidget-Spinner approved these changes
@brandtbucher brandtbucher Awaiting requested review from brandtbucher
+1 more reviewer
@tekknolagi tekknolagi tekknolagi left review comments
Reviewers whose approvals may not affect merge requirements

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

@diegorusso @Fidget-Spinner @tekknolagi @tomasr8
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.