# Very slow loop

**URL:** <https://discourse.julialang.org/t/very-slow-loop/53608>\
**Category:** Performance\
**Tags:** loops\
**Created:** [January 19, 2021, 2:07pm UTC](https://discourse.julialang.org/t/very-slow-loop/53608 "2021-01-19T14:07:25Z")\
**Posts on this page:** 1\
**Showing post:** 25

<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:** [January 21, 2021, 12:54pm UTC](https://discourse.julialang.org/t/very-slow-loop/53608/25 "2021-01-21T12:54:32Z")

</div>

You can make `cat` type-stable, like so:

```julia
julia> @code_warntype cat(B, B, dims=2)
...
Body::Any

julia> @code_warntype hcat(B, B)
...
Body::Matrix{Int64}

julia> @code_warntype cat(B, B, dims=Val(2))
...
Body::Matrix{Int64}

```

The issue with the first one is that `cat(B, B; dims=1) isa Vector` – same input types, but different output.

---

_[View the full topic](https://discourse.julialang.org/t/very-slow-loop/53608)._
