Repository navigation
Commit 33a4871
gh-87613: Use Argument Clinic vectorcall for zip
zip had no vectorcall, so every call built an args tuple and a kwargs
dict, and strict=True also went through PyArg_ParseTupleAndKeywords with
a temporary empty tuple. Argument error messages are unchanged except
for unknown keywords: `zip(strict=1, x=2)` now reports "got an
unexpected keyword argument 'x'" instead of "takes at most 1 keyword
argument (2 given)". The docstring gains a summary line;
`__text_signature__` is unchanged.
pyperf microbenchmark (PGO+LTO, run serially):
| Benchmark | base | zip |
|------------------------|:-------:|:---------------------:|
| zip(a, b, strict=True) | 118 ns | 61.5 ns: 1.92x faster |
| zip(a, b) | 64.9 ns | 53.1 ns: 1.22x faster |
| zip(a) | 55.0 ns | 47.1 ns: 1.17x faster |
| list(zip(a, b)) | 123 ns | 113 ns: 1.09x faster |
| zip() | 27.4 ns | 25.7 ns: 1.07x faster |
| Sub(a, b) | 71.5 ns | 70.6 ns: 1.01x faster |
Benchmark hidden because not significant (1): zip.`__new__`
Benchmark code:
```python
import pyperf
runner = pyperf.Runner()
setup = "a = (1, 2, 3); b = [4, 5, 6]"
for stmt in ["zip()", "zip(a)", "zip(a, b)", "zip(a, b, strict=True)",
"list(zip(a, b))"]:
runner.timeit(stmt, stmt, setup)
runner.timeit('zip.`__new__`', 'new(zip, a, b)', setup + '; new = zip.__new__')
runner.timeit('Sub(a, b)', 'S(a, b)', setup + '\nclass S(zip): pass')
```
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>1 parent c121f81 commit 33a4871
2 files changed
Lines changed: 137 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3139 | 3139 | | |
3140 | 3140 | | |
3141 | 3141 | | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
3142 | 3165 | | |
3143 | | - | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
3144 | 3170 | | |
3145 | 3171 | | |
3146 | 3172 | | |
3147 | 3173 | | |
3148 | 3174 | | |
3149 | | - | |
3150 | | - | |
3151 | | - | |
3152 | | - | |
3153 | | - | |
3154 | | - | |
3155 | | - | |
3156 | | - | |
3157 | | - | |
3158 | | - | |
3159 | | - | |
3160 | | - | |
3161 | | - | |
3162 | | - | |
3163 | | - | |
3164 | | - | |
3165 | | - | |
3166 | | - | |
3167 | | - | |
3168 | | - | |
| 3175 | + | |
3169 | 3176 | | |
3170 | 3177 | | |
3171 | 3178 | | |
3172 | 3179 | | |
3173 | 3180 | | |
3174 | 3181 | | |
3175 | | - | |
3176 | | - | |
| 3182 | + | |
3177 | 3183 | | |
3178 | 3184 | | |
3179 | 3185 | | |
| |||
3345 | 3351 | | |
3346 | 3352 | | |
3347 | 3353 | | |
3348 | | - | |
3349 | | - | |
3350 | | - | |
3351 | | - | |
3352 | | - | |
3353 | | - | |
3354 | | - | |
3355 | | - | |
3356 | | - | |
3357 | | - | |
3358 | | - | |
3359 | | - | |
3360 | | - | |
3361 | | - | |
3362 | | - | |
3363 | 3354 | | |
3364 | 3355 | | |
3365 | 3356 | | |
| |||
3383 | 3374 | | |
3384 | 3375 | | |
3385 | 3376 | | |
3386 | | - | |
| 3377 | + | |
3387 | 3378 | | |
3388 | 3379 | | |
3389 | 3380 | | |
| |||
3402 | 3393 | | |
3403 | 3394 | | |
3404 | 3395 | | |
| 3396 | + | |
3405 | 3397 | | |
3406 | 3398 | | |
3407 | 3399 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments