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

gh-131798: JIT: Narrow the return type of _CALL_LEN to int by diegorusso · Pull Request #132940 · python/cpython · GitHub

/ cpython Public

gh-131798: JIT: Narrow the return type of _CALL_LEN to int - #132940

Merged
Fidget-Spinner merged 4 commits into
python:mainfrom
diegorusso:call-len
Apr 25, 2025
Merged

gh-131798: JIT: Narrow the return type of _CALL_LEN to int#132940
Fidget-Spinner merged 4 commits into
python:mainfrom
diegorusso:call-len

Conversation

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

Copy link
Copy Markdown
Contributor

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

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

Fidget-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.

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

Thanks!

Copy link
Copy Markdown
Member

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

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)

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

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)

Copy link
Copy Markdown
Contributor 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

Good point, I'll do it.

Copy link
Copy Markdown
Contributor 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

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

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

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

Fidget-Spinner and others added 2 commits April 26, 2025 01:48
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.

4 participants


Back | FazBrowse Home | New Git URL