Skip to content

Use :contiguous in N-index pyarray_offset - #836

Merged
cjdoris merged 2 commits into
JuliaPy:v1from
Beforerr:v1-pyarray-contiguous-offset
Oct 24, 2026
Merged

cjdoris merged 2 commits into
JuliaPy:v1from
Beforerr:v1-pyarray-contiguous-offset

Conversation

@Beforerr

@Beforerr Beforerr commented Oct 6, 2026

Copy link
Copy Markdown

The Vararg method of pyarray_offset ignored :contiguous. For N == 1 it's also the one picked over pyarray_offset(x, i::Int), so sum over a contiguous vector still multiplied by the runtime stride and didn't vectorise.

sum of a 1e7 Float32 vector, Julia 1.13.1, Apple M1: 4.44 ms before, 0.45 ms after, 0.44 ms for Array.

This also speeds up Cartesian indexing of contiguous N-d arrays. #835 does the same for 0.9 without the flag.

Beforerr and others added 2 commits October 5, 2026 18:15
The Vararg method ignored the flag, and it is also the one picked for
1-D linear indexing, so sum over a contiguous vector didn't vectorise.
@cjdoris
cjdoris merged commit 28ab334 into JuliaPy:v1 Oct 24, 2026
17 of 18 checks passed
@cjdoris

cjdoris commented Oct 24, 2026

Copy link
Copy Markdown
Member

Thanks! I simplified it a bit.

@Beforerr
Beforerr deleted the v1-pyarray-contiguous-offset branch October 25, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants