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

checkexpr: cache type of container literals when possible #12707

Merged
merged 1 commit into from May 20, 2022

Commits on May 16, 2022

  1. checkexpr: cache type of container literals when possible

    When a container (list, set, tuple, or dict) literal expression is
    used as an argument to an overloaded function it will get repeatedly
    typechecked. This becomes particularly problematic when the expression
    is somewhat large, as seen in python#9427
    
    To avoid repeated work, add a new cache in ExprChecker, mapping the AST
    node to the resolved type of the expression. Right now the cache is
    only used in the fast path, although it could conceivably be leveraged
    for the slow path as well in a follow-up commit.
    
    To further reduce duplicate work, when the fast-path doesn't work, we
    use the cache to make a note of that, to avoid repeatedly attempting to
    take the fast path.
    
    Fixes python#9427
    huguesb committed May 16, 2022
    Copy the full SHA
    af675fe View commit details
    Browse the repository at this point in the history