Bug report
Bug description:
The optimizer is replacing _GUARD_CODE_VERSION with a watcher, which would be fine if the code object were known.
However, the code object is just the one observed during tracing. The one observed during execution could be different, which is why the guard was added in the first place.
We should only remove the guard if the code version is known.
Correct optimizations would be:
- Only remove the first guard (and add the code watcher)
- If the function is known and its version is known, remove the guard.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Bug report
Bug description:
The optimizer is replacing
_GUARD_CODE_VERSIONwith a watcher, which would be fine if the code object were known.However, the code object is just the one observed during tracing. The one observed during execution could be different, which is why the guard was added in the first place.
We should only remove the guard if the code version is known.
Correct optimizations would be:
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs