Commit 6600073
authored
[mypyc] Use per-type free "lists" for nested functions (#19390)
Often at most one instance is allocated at any given time, so this
improves performance quite significantly in common cases. Uses the
freelist feature introduced in #19316.
This speeds up self check by about 0.5% (measured 100 samples). Speeds
up this microbenchmark that gets close to the maximal benefit by about
90%:
```
def f(x: int) -> int:
def inc(y: int) -> int:
return y + 1
return inc(x)
def bench(n: int) -> None:
for x in range(n):
f(x)
from time import time
bench(1000)
t0 = time()
bench(50 * 1000 * 1000)
print(time() - t0)
```1 parent ada0d2a commit 6600073
2 files changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
0 commit comments