◐ Shell
clean mode source ↗

gh-119180: Avoid going through AST and eval() when possible in annotationlib by JelleZijlstra · Pull Request #124337 · python/cpython

added 4 commits

September 22, 2024 14:25
…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.
…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.

vstinner

vstinner

Co-authored-by: Victor Stinner <vstinner@python.org>

AlexWaygood

AlexWaygood

emilyemorehouse added a commit to lysnikolaou/cpython that referenced this pull request

Sep 26, 2024