Commit ac11374
committed
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 #9427
To avoid repeated work, add a new field in the relevant AST nodes to
cache 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 #94271 parent 9f8b814 commit ac11374
2 files changed
+38
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3259 | 3259 | | |
3260 | 3260 | | |
3261 | 3261 | | |
3262 | | - | |
| 3262 | + | |
3263 | 3263 | | |
3264 | 3264 | | |
3265 | | - | |
| 3265 | + | |
3266 | 3266 | | |
3267 | 3267 | | |
3268 | | - | |
| 3268 | + | |
3269 | 3269 | | |
3270 | 3270 | | |
3271 | 3271 | | |
| |||
3280 | 3280 | | |
3281 | 3281 | | |
3282 | 3282 | | |
| 3283 | + | |
| 3284 | + | |
3283 | 3285 | | |
3284 | | - | |
| 3286 | + | |
3285 | 3287 | | |
3286 | 3288 | | |
| 3289 | + | |
3287 | 3290 | | |
3288 | 3291 | | |
3289 | 3292 | | |
3290 | 3293 | | |
| 3294 | + | |
3291 | 3295 | | |
3292 | | - | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
3293 | 3299 | | |
3294 | | - | |
3295 | | - | |
| 3300 | + | |
| 3301 | + | |
3296 | 3302 | | |
3297 | | - | |
| 3303 | + | |
3298 | 3304 | | |
3299 | 3305 | | |
3300 | 3306 | | |
| |||
3313 | 3319 | | |
3314 | 3320 | | |
3315 | 3321 | | |
3316 | | - | |
| 3322 | + | |
3317 | 3323 | | |
3318 | | - | |
3319 | | - | |
| 3324 | + | |
| 3325 | + | |
3320 | 3326 | | |
3321 | 3327 | | |
3322 | 3328 | | |
| |||
3366 | 3372 | | |
3367 | 3373 | | |
3368 | 3374 | | |
3369 | | - | |
| 3375 | + | |
3370 | 3376 | | |
3371 | 3377 | | |
3372 | 3378 | | |
| |||
3392 | 3398 | | |
3393 | 3399 | | |
3394 | 3400 | | |
| 3401 | + | |
| 3402 | + | |
3395 | 3403 | | |
3396 | 3404 | | |
3397 | 3405 | | |
| |||
3405 | 3413 | | |
3406 | 3414 | | |
3407 | 3415 | | |
| 3416 | + | |
3408 | 3417 | | |
3409 | 3418 | | |
3410 | 3419 | | |
3411 | 3420 | | |
3412 | 3421 | | |
3413 | 3422 | | |
3414 | 3423 | | |
| 3424 | + | |
3415 | 3425 | | |
3416 | 3426 | | |
| 3427 | + | |
3417 | 3428 | | |
3418 | | - | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
3419 | 3432 | | |
3420 | 3433 | | |
3421 | 3434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2026 | 2026 | | |
2027 | 2027 | | |
2028 | 2028 | | |
2029 | | - | |
| 2029 | + | |
2030 | 2030 | | |
2031 | 2031 | | |
| 2032 | + | |
2032 | 2033 | | |
2033 | 2034 | | |
2034 | 2035 | | |
2035 | 2036 | | |
| 2037 | + | |
2036 | 2038 | | |
2037 | 2039 | | |
2038 | 2040 | | |
| |||
2041 | 2043 | | |
2042 | 2044 | | |
2043 | 2045 | | |
2044 | | - | |
| 2046 | + | |
2045 | 2047 | | |
2046 | 2048 | | |
| 2049 | + | |
2047 | 2050 | | |
2048 | 2051 | | |
2049 | 2052 | | |
2050 | 2053 | | |
| 2054 | + | |
2051 | 2055 | | |
2052 | 2056 | | |
2053 | 2057 | | |
| |||
2058 | 2062 | | |
2059 | 2063 | | |
2060 | 2064 | | |
2061 | | - | |
| 2065 | + | |
2062 | 2066 | | |
2063 | 2067 | | |
| 2068 | + | |
2064 | 2069 | | |
2065 | 2070 | | |
2066 | 2071 | | |
2067 | 2072 | | |
| 2073 | + | |
2068 | 2074 | | |
2069 | 2075 | | |
2070 | 2076 | | |
| |||
2073 | 2079 | | |
2074 | 2080 | | |
2075 | 2081 | | |
2076 | | - | |
| 2082 | + | |
2077 | 2083 | | |
2078 | 2084 | | |
| 2085 | + | |
2079 | 2086 | | |
2080 | 2087 | | |
2081 | 2088 | | |
2082 | 2089 | | |
| 2090 | + | |
2083 | 2091 | | |
2084 | 2092 | | |
2085 | 2093 | | |
| |||
0 commit comments