A function version may be modified midway in the trace, so we need to recheck and add a watcher in the first check.
(All credits go to @Fidget-Spinner for pointing this out, #145080 (comment))
Ken Jin suggested to restore the old optimization instead as the fix above the will result in quite bad performance, as it’s calling it on every function deallocation.
The PR will also include a tiny bugfix found in _Py_uop_sym_set_func_version
changed the title [-]JIT: Function version is not re-checked in the optimizer for `_CHECK_FUNCTION_VERSION`[/-][+]JIT: Restore previous optimization for `_CHECK_FUNCTION_VERSION`[/+]on Mar 22, 2026
changed the title [-]JIT: Restore previous optimization for `_CHECK_FUNCTION_VERSION`[/-][+]JIT: Optimization in `_CHECK_FUNCTION_VERSION` is wrong[/+]on Mar 22, 2026
Activity
gh-146261: Fix bug in `_Py_uop_sym_set_func_version` (GH-146291)
Merge branch 'main' of github.com:python/cpython into fix-pythongh-13…
gh-146261: JIT: protect against function version changes (#146300)
Revert "pythongh-146261: JIT: protect against function version changes (
StanFromIreland commented on Apr 19, 2026
Triage: Can this be closed?
pythongh-146261: Fix bug in `_Py_uop_sym_set_func_version` (pythonGH-…
pythongh-146261: JIT: protect against function version changes (pytho…