Repository navigation
Commit e8bc97b
authored
Add AC vectorcall for `Template` and `Interpolation`.
`Template` now raises `TypeError: Template() takes no keyword arguments` for kwargs instead of `TypeError: Template.__new__ only accepts *args arguments`.
Benchmark:
```
+--------------------------------+--------+------------------------+
| Benchmark | main | patch |
+================================+========+========================+
| Template('a') | 177 ns | 134 ns: 1.32x faster |
| Interpolation(1) | 148 ns | 105 ns: 1.41x faster |
+--------------------------------+--------+------------------------+
| Geometric mean | (ref) | 1.36x faster |
+--------------------------------+--------+------------------------+
```
```python
import pyperf
SETUP = """
from string.templatelib import Template, Interpolation
"""
CASES = [
("Template('a')", "Template('a')"),
('Interpolation(1)', 'Interpolation(1)')
]
runner = pyperf.Runner()
for name, stmt in CASES:
runner.timeit(name, stmt=stmt, setup=SETUP)
```
1 parent 9de76f2 commit e8bc97b
4 files changed
Lines changed: 144 additions & 17 deletions
File tree
- Objects
- clinic
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
92 | 106 | | |
93 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
94 | 110 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | 111 | | |
102 | 112 | | |
103 | 113 | | |
104 | 114 | | |
105 | | - | |
106 | | - | |
| 115 | + | |
| 116 | + | |
107 | 117 | | |
108 | 118 | | |
109 | 119 | | |
| |||
142 | 152 | | |
143 | 153 | | |
144 | 154 | | |
145 | | - | |
146 | | - | |
| 155 | + | |
| 156 | + | |
147 | 157 | | |
148 | 158 | | |
149 | 159 | | |
| |||
391 | 401 | | |
392 | 402 | | |
393 | 403 | | |
| 404 | + | |
394 | 405 | | |
395 | 406 | | |
396 | 407 | | |
| |||
0 commit comments