# Strange case of permutedims() preventing further growth of its input

**URL:** <https://discourse.julialang.org/t/strange-case-of-permutedims-preventing-further-growth-of-its-input/61913>\
**Category:** New to Julia\
**Created:** [May 27, 2021, 11:20am UTC](https://discourse.julialang.org/t/strange-case-of-permutedims-preventing-further-growth-of-its-input/61913 "2021-05-27T11:20:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vvbond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vvbond/32/10105_2.png) [@vvbond](https://discourse.julialang.org/u/vvbond)\
**Post date:** [May 27, 2021, 11:20am UTC](https://discourse.julialang.org/t/strange-case-of-permutedims-preventing-further-growth-of-its-input/61913/1 "2021-05-27T11:20:55Z")

</div>

Most probably it is a feature, not a bug, but the following behavior is a surprising inconvenience for me. I’d appreciate if some expert would care to comment or suggest a workaround.

```julia
julia> a = [1,2,3]
3-element Vector{Int64}:
 1
 2
 3

julia> b = permutedims(a)
1×3 Matrix{Int64}:
 1 2 3

julia> push!(a, 4)
ERROR: cannot resize array with shared data
Stacktrace:
 [1] _growend!
   @ ./array.jl:884 [inlined]
 [2] push!(a::Vector{Int64}, item::Int64)
   @ Base ./array.jl:929
 [3] top-level scope
   @ REPL[8]:1

```

---

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [May 27, 2021, 11:35am UTC](https://discourse.julialang.org/t/strange-case-of-permutedims-preventing-further-growth-of-its-input/61913/2 "2021-05-27T11:35:07Z")

</div>

Related:  
[https://github.com/JuliaLang/julia/issues/33143](https://github.com/JuliaLang/julia/issues/33143)

I think there’s another issue too but I can’t seem to find it right now. Does this workaround work for your case?

```julia
julia> a = [1,2,3]
3-element Vector{Int64}:
 1
 2
 3

julia> b = permutedims(copy(a))
1×3 Matrix{Int64}:
 1 2 3

julia> push!(a, 4)
4-element Vector{Int64}:
 1
 2
 3
 4

```

---

<div class="post-metadata">

**Author:** ![vvbond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vvbond/32/10105_2.png) [@vvbond](https://discourse.julialang.org/u/vvbond)\
**Post date:** [May 27, 2021, 11:38am UTC](https://discourse.julialang.org/t/strange-case-of-permutedims-preventing-further-growth-of-its-input/61913/3 "2021-05-27T11:38:30Z")

</div>

Thanks! It’s amazing how reactive the Julia community is.

---

<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:** [May 27, 2021, 11:38am UTC](https://discourse.julialang.org/t/strange-case-of-permutedims-preventing-further-growth-of-its-input/61913/4 "2021-05-27T11:38:52Z")

</div>

It’s a bit strange (although documented) that the data is shared for a vector but not for arrays of other dimensionalities

---

<div class="post-metadata">

**Author:** ![vvbond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vvbond/32/10105_2.png) [@vvbond](https://discourse.julialang.org/u/vvbond)\
**Post date:** [May 27, 2021, 11:59am UTC](https://discourse.julialang.org/t/strange-case-of-permutedims-preventing-further-growth-of-its-input/61913/5 "2021-05-27T11:59:34Z")

</div>

Good point. I was not aware of that.
