Skip to content

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

Merged
markshannon merged 3 commits intopython: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 intopython:mainfrom
Fidget-Spinner:turn_off_code_opt

Conversation

@Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Mar 13, 2026

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
Member Author

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

@markshannon markshannon changed the title gh-144651: Disable over-aggressive optimization for _GUARD_CODE_VERSION gh-146018: Disable over-aggressive optimization for _GUARD_CODE_VERSION Mar 16, 2026
@markshannon
Copy link
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 reopened this Mar 16, 2026
@markshannon markshannon merged commit 182aea2 into python:main Mar 16, 2026
165 of 169 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants