]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-119180: Avoid going through AST and eval() when possible in annotationlib (#124337)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Wed, 25 Sep 2024 21:14:03 +0000 (14:14 -0700)
committerGitHub <noreply@github.com>
Wed, 25 Sep 2024 21:14:03 +0000 (21:14 +0000)
commit17a544b257ee3aeaa525350717ee56fd409d9c08
treef95619d160ac984403339ca67b25fabfc4eb97da
parent9d8f2d8e08336695fdade5846da4bbcc3eb5f152
gh-119180: Avoid going through AST and eval() when possible in annotationlib (#124337)

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.

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/annotationlib.py
Lib/test/test_annotationlib.py