Skip to content

Over-aggressive optimization for _GUARD_CODE_VERSION #146018

@markshannon

Description

@markshannon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions