I noticed in v0.7 that if I want a Vector
out of a reinterpret
operation rather than a ReinterpretArray
that using the Vector
constructor to do the conversion comes with a significant allocation cost proportional to the size of the array, seems like data is being copied. Is there a straightforward way to get a Vector
essentially pointing to the same data instead of copying?
Similar post: Big overhead with the new lazy reshape/reinterpret
MWE:
a = ones(Int, 10);
b = reinterpret(NTuple{2,Int}, a);
c = Array(reinterpret(NTuple{2,Int}, a));
a[1:2]
#=
2-element Array{Int64,1}:
1
1
=#
b[1]
#(1, 1)
c[1]
#(1, 1)
a[1] = 2;
b[1]
#(2, 1)
c[1]
#(1, 1)