Skip to content

gh-162350: Use AC for array.array constructor - #162419

Open
skirpichev wants to merge 1 commit into
python:mainfrom
skirpichev:array.array-vc/162350
Open

skirpichev wants to merge 1 commit into
python:mainfrom
skirpichev:array.array-vc/162350

Conversation

@skirpichev

@skirpichev skirpichev commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

This fixes it's signature and adds also support for Vectorcall protocol.

This fixes it's signature and adds also support for Vectorcall protocol.
@skirpichev

Copy link
Copy Markdown
Member Author

Microbenchmark (default options, gcc 14.2):

Benchmark ref patch
array of 0 elts 5.08 us 3.86 us: 1.32x faster
array of 1 elts 6.23 us 5.02 us: 1.24x faster
array of 2 elts 6.51 us 5.29 us: 1.23x faster
array of 3 elts 6.79 us 5.57 us: 1.22x faster
array of 100 elts 30.8 us 30.9 us: 1.00x slower
Geometric mean (ref) 1.20x faster
Details
from array import array
import pyperf
runner = pyperf.Runner()
tp = 'i'
for xs in [[], [1], [1, 2], [1, 2, 3], list(range(100))]:
    s = f"array of {len(xs)} elts"
    runner.bench_func(s, array, tp, xs)
array of 0 elts: Mean +- std dev: [ref] 5.08 us +- 0.13 us -> [patch] 3.86 us +- 0.02 us: 1.32x faster
array of 1 elts: Mean +- std dev: [ref] 6.23 us +- 0.04 us -> [patch] 5.02 us +- 0.23 us: 1.24x faster
array of 2 elts: Mean +- std dev: [ref] 6.51 us +- 0.40 us -> [patch] 5.29 us +- 0.03 us: 1.23x faster
array of 3 elts: Mean +- std dev: [ref] 6.79 us +- 0.27 us -> [patch] 5.57 us +- 0.04 us: 1.22x faster
array of 100 elts: Mean +- std dev: [ref] 30.8 us +- 0.2 us -> [patch] 30.9 us +- 0.1 us: 1.00x slower

Geometric mean: 1.20x faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant