Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-119180: Avoid going through AST and eval() when possible in annotationlib #124337

Merged
merged 11 commits into from
Sep 25, 2024

Commits on Sep 22, 2024

  1. pythongh-119180: Fix bug where fwdrefs were evaluated in the annotati…

    …onlib module scope
    
    We were sometimes passing None as the globals argument to eval(), which makes it
    inherit the globals from the calling scope. Instead, ensure that globals is always
    non-None. The test was passing accidentally because I passed "annotationlib" as a
    module object; fix that. Also document the parameters to ForwardRef() and remove
    two unused private ones.
    JelleZijlstra committed Sep 22, 2024
    Configuration menu
    Copy the full SHA
    293fb0a View commit details
    Browse the repository at this point in the history
  2. pythongh-119180: Optimize annotationlib to avoid creation of AST node…

    …s and eval()
    
    Often, ForwardRefs represent a single simple name. In that case, we
    can avoid going through the overhead of creating AST nodes and code
    objects and calling eval(): we can simply look up the name directly
    in the relevant namespaces.
    JelleZijlstra committed Sep 22, 2024
    Configuration menu
    Copy the full SHA
    3cfa504 View commit details
    Browse the repository at this point in the history

Commits on Sep 23, 2024

  1. add a test case

    JelleZijlstra committed Sep 23, 2024
    Configuration menu
    Copy the full SHA
    eaea393 View commit details
    Browse the repository at this point in the history
  2. more tests

    JelleZijlstra committed Sep 23, 2024
    Configuration menu
    Copy the full SHA
    e274f99 View commit details
    Browse the repository at this point in the history
  3. fmt

    JelleZijlstra committed Sep 23, 2024
    Configuration menu
    Copy the full SHA
    0dc0a68 View commit details
    Browse the repository at this point in the history

Commits on Sep 24, 2024

  1. Configuration menu
    Copy the full SHA
    2f5d504 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    892efe9 View commit details
    Browse the repository at this point in the history
  3. one more test

    JelleZijlstra committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    fefa126 View commit details
    Browse the repository at this point in the history
  4. Apply suggestions from code review

    Co-authored-by: Victor Stinner <vstinner@python.org>
    JelleZijlstra and vstinner authored Sep 24, 2024
    Configuration menu
    Copy the full SHA
    ab30124 View commit details
    Browse the repository at this point in the history

Commits on Sep 25, 2024

  1. Configuration menu
    Copy the full SHA
    4b1214e View commit details
    Browse the repository at this point in the history
  2. PR feedback

    JelleZijlstra committed Sep 25, 2024
    Configuration menu
    Copy the full SHA
    cebb78e View commit details
    Browse the repository at this point in the history