# IF...ELSEIF...ELSE performance

**URL:** https://discourse.julialang.org/t/if-elseif-else-performance/24622
**Category:** Performance
**Created:** [May 26, 2019, 7:12pm UTC](https://discourse.julialang.org/t/if-elseif-else-performance/24622 "2019-05-26T19:12:33Z")
**Posts on this page:** 1
**Showing post:** 18

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [May 29, 2019, 1:47pm UTC](https://discourse.julialang.org/t/if-elseif-else-performance/24622/18 "2019-05-29T13:47:06Z")

</div>

I think a few high-level lessons can be gleaned from this thread:

1. Dicts are impressively fast.
2. What LLVM does with an if/else nest is opaque and unpredictable. If that’s the only way to express your computation, so be it, but if there’s a more structured way, you’re probably better off preserving and exposing the structure.
3. Tuples really rule for performance.

To a large extent, tuples exist to hint to the compiler that it should reason about the individual types and number of elements in an immutable collection. Otherwise we’d just use `Vector{Any}`—but that type serves as a hint of precisely the opposite: it tells the compiler not to worry about how many or what the specific types in a collection are.

---

_[View the full topic](https://discourse.julialang.org/t/if-elseif-else-performance/24622)._
