# Return type of blockdiag?

**URL:** <https://discourse.julialang.org/t/return-type-of-blockdiag/17172>\
**Category:** Performance\
**Tags:** type\
**Created:** [November 5, 2018, 2:29pm UTC](https://discourse.julialang.org/t/return-type-of-blockdiag/17172 "2018-11-05T14:29:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![teored90](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teored90/32/5142_2.png) [@teored90](https://discourse.julialang.org/u/teored90)\
**Post date:** [November 5, 2018, 2:29pm UTC](https://discourse.julialang.org/t/return-type-of-blockdiag/17172/1 "2018-11-05T14:29:05Z")

</div>

I was studying the type stability of my code (I’m still very bad at it) and I bumped into this weird behavior with `SparseArrays.blockdiag()`:

```julia
julia> using SparseArrays
julia> A = [sprand(100, 100, .1) for i = 1: 15]; @code_warntype blockdiag(A...);

Body::SparseMatrixCSC{Float64,Int64}
...

```

But if I make a 16-element array (or bigger)

```julia
julia> A = [sprand(100, 100, .1) for i = 1: 16]; @code_warntype blockdiag(A...);

Body::SparseMatrixCSC{_1,_2} where _2 where _1
...

```

I’m omitting the complete output of @code\_warntype, but you can easily get it on your computer.

The size of the sparse matrices doesn’t seem to affect the behavior.

What is going on here?

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [November 5, 2018, 2:43pm UTC](https://discourse.julialang.org/t/return-type-of-blockdiag/17172/2 "2018-11-05T14:43:46Z")

</div>

Seems like your hitting a heuristic cutoff in the compiler. AFAIU, these cutoffs are sometimes necessary to avoid long (or even endless) compilation times.

Hopefully someone more qualified will answer your question in more detail.
