Should reinterpret return the parent array if the eltype is unchanged?

For example:

julia> a = [1 + im, 2 + 2im]
2-element Array{Complex{Int64},1}:
 1 + 1im
 2 + 2im

julia> reinterpret(eltype(a), a)
2-element reinterpret(Complex{Int64}, ::Array{Complex{Int64},1}):
 1 + 1im
 2 + 2im

Do we need the wrapper in this particular case? I realize that it is a special case, but it might lead to some performance gains such as

julia> a = [Complex(i,2i) for i in 1:1000];

julia> ra = reinterpret(eltype(a), a);

julia> @btime sum($a);
  543.154 ns (0 allocations: 0 bytes)

julia> @btime sum($ra);
  2.415 μs (0 allocations: 0 bytes)

Looks like this is fixed on 1.6:

julia> summary(ra)
"1000-element Vector{Complex{Int64}}"

julia> @btime sum($a);
  285.829 ns (0 allocations: 0 bytes)

julia> @btime sum($ra);
  284.117 ns (0 allocations: 0 bytes)
2 Likes