Skip to content

gh-146018: Disable over-aggressive optimization for _GUARD_CODE_VERSION - #145923

Merged
markshannon merged 3 commits into
python:mainfrom
Fidget-Spinner:turn_off_code_opt
Mar 16, 2026
Merged

gh-146018: Disable over-aggressive optimization for _GUARD_CODE_VERSION#145923
markshannon merged 3 commits into
python:mainfrom
Fidget-Spinner:turn_off_code_opt

Conversation

@Fidget-Spinner

@Fidget-SpinnerFidget-Spinner commented Mar 13, 2026

Copy link
Copy Markdown
Member

We still need the first check in the trace, the subsequent checks can be elided.

For now, let's just restore all checks for correctness reasons. We can come up with a smart way to track whether a code object has been checked in the future.

I don't know how to test this, as any assigning of code object on the function invalidates the function version. We'd need some indirect way of setting the code version?

Issue: #146018

@Fidget-Spinner

Copy link
Copy Markdown
MemberAuthor

@markshannon I'm not actually sure this fix is right. It also smells like a possible function version problem in the function object files. Hopefully this helps you/gives you a solid hint.

@markshannonmarkshannon changed the title gh-144651: Disable over-aggressive optimization for _GUARD_CODE_VERSIONgh-146018: Disable over-aggressive optimization for _GUARD_CODE_VERSIONMar 16, 2026
@markshannon

Copy link
Copy Markdown
Member

This fix is correct. I don't think the problem is that the function version number is modified, but that we are seeing a different function.

@markshannon
markshannon merged commit 182aea2 into python:mainMar 16, 2026
165 of 169 checks passed
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Fidget-Spinner@markshannon@savannahostrowski