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

**URL:** <https://discourse.julialang.org/t/should-reinterpret-return-the-parent-array-if-the-eltype-is-unchanged/51920>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 16, 2020, 8:34am UTC](https://discourse.julialang.org/t/should-reinterpret-return-the-parent-array-if-the-eltype-is-unchanged/51920 "2020-12-16T08:34:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [December 16, 2020, 8:34am UTC](https://discourse.julialang.org/t/should-reinterpret-return-the-parent-array-if-the-eltype-is-unchanged/51920/1 "2020-12-16T08:34:31Z")

</div>

For example:

```julia
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
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)

```

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [December 16, 2020, 8:44am UTC](https://discourse.julialang.org/t/should-reinterpret-return-the-parent-array-if-the-eltype-is-unchanged/51920/2 "2020-12-16T08:44:47Z")

</div>

Looks like this is fixed on 1.6:

```julia
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)

```
