Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

getindex(S::SubArray{T,2}, i::Integer) allocates memory when it probably shouldn't #3790

Closed
timholy opened this Issue · 0 comments

1 participant

@timholy
Collaborator
julia> A = reshape(1:3004*3002, 3004, 3002);

julia> sA = sub(A, 1:3003, 1:3002);

julia> @time sum(A)
elapsed time: 0.022972412 seconds (121728 bytes allocated)
40662238653036

julia> @time sum(A)
elapsed time: 0.027780444 seconds (64 bytes allocated)
40662238653036

julia> @time sum(sA)
elapsed time: 0.599137738 seconds (144450680 bytes allocated)
40648698114024

julia> @time sum(sA)
elapsed time: 0.58232922 seconds (144232032 bytes allocated)
40648698114024

The specialized implementation at subarray.jl: 176 would seem to suggest that it's not necessary.

@timholy timholy closed this issue from a commit
@timholy timholy Fix #3790 caabd83
@timholy timholy closed this in caabd83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.