Here we’re about 5x slower. In my larger case we’re about 50x slower, but I will check there for type instability.
Forgive my ignorance, but what is Cartesian indexing?
If an array isn't stored continuously in memory for linear indexing, converting to the Cartesian indices is very expensive (because it requires integer division, which is a surprising slow). The new `eachindex` method in 0.4 returns an iterator to go over all the Cartesian indices very quickly.
Thanks for chiming in, Matt.
I should have added that there are _some_ SubArrays that do have efficient
linear indexing: sub(A, :, 3:5) and sub(A, 2, :), for a matrix A, are two
examples. (The latter in particular is one of the advantages of 0.4's
SubArrays over ArrayViews.) But in general it's not efficient.
But Sebastian, please do file those issues. It's hard to keep track of what
needs updating, and issues are vastly preferable to posts to julia-users. For
instance, it's already gone clean out of my head what function was slow with
SubArrays :-).
--Tim