# @code\_warntype shows lots of Union{Nothing, Tuple{Int64, Int64}}

**URL:** https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748
**Category:** Performance
**Created:** [May 7, 2021, 10:48pm UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748 "2021-05-07T22:48:02Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![rpmuller](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rpmuller/32/2262_2.png) [@rpmuller](https://discourse.julialang.org/u/rpmuller)
#### Post date: [May 7, 2021, 10:48pm UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748/1 "2021-05-07T22:48:02Z")

</div>

I’m working through @ChrisRackauckas excellent article [7 Julia Gotchas and How to Handle Them - Stochastic Lifestyle](https://www.stochasticlifestyle.com/7-julia-gotchas-handle/). One of his big recommendations is to use `@code_warntype`.

I already found an untyped container that made things a lot faster when I fixed it.

However, now I see lots of `Union{Nothing, Tuple{Int64, Int64}}`. I’m looking through [my code](https://github.com/rpmuller/MolecularIntegrals.jl/blob/master/src/HGP.jl) (the `vrr` routine, not that I’m asking anyone to debug code for me), and I just can’t find anything that would lead to variables of that type. The only other hint I have is that all of these variables have an `@_53` or some other number in front of them, which I’m guessing means that they’re intermediate variables, i.e.:

```julia
  i@_52::Int64
  @_53::Union{Nothing, Tuple{Int64, Int64}}
  @_54::Union{Nothing, Tuple{Int64, Int64}}
  @_55::Union{Nothing, Tuple{Int64, Int64}}
  @_56::Union{Nothing, Tuple{Int64, Int64}}
  c_i::Float64

```

Does this ring any bells for people, or can people suggest useful directions to pursue?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [May 7, 2021, 11:07pm UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748/2 "2021-05-07T23:07:56Z")

</div>

The main place you see `Union{Nothing, something_else}` is from `for` loops. These lower to `iterate(iter,state)` which either returns the next state or `nothing`.

You don’t need to worry about this. Julia is able to generate efficient code for small unions (unions of 4 or less types).

---

<div class="post-metadata">

### Author: ![rpmuller](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rpmuller/32/2262_2.png) [@rpmuller](https://discourse.julialang.org/u/rpmuller)
#### Post date: [May 7, 2021, 11:29pm UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748/3 "2021-05-07T23:29:59Z")

</div>

Excellent.That makes a lot of sense. Thanks for your help!

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 8, 2021, 12:08am UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748/4 "2021-05-08T00:08:15Z")

</div>

> [@Oscar\_Smith](#):
>
> You don’t need to worry about this. Julia is able to generate efficient code for small unions (unions of 4 or less types).

Yeah, Julia’s compiler fixed this and a lot of the other gotchas.

I should write a follow up post, “7 Julia Gotchas and How They Were Handled”

---

<div class="post-metadata">

### Author: ![rpmuller](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rpmuller/32/2262_2.png) [@rpmuller](https://discourse.julialang.org/u/rpmuller)
#### Post date: [May 8, 2021, 12:11am UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748/5 "2021-05-08T00:11:00Z")

</div>

@ChrisRackauckas Would love to see a follow-up article. That, plus the [Julia Performance Tips](https://docs.julialang.org/en/v1/manual/performance-tips/), have been the best resources I’ve found to speeding my code.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 8, 2021, 12:11am UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748/6 "2021-05-08T00:11:44Z")

</div>

These days I’d recommend my lecture notes on serial code performance:

[https://mitmath.github.io/18337/lecture2/optimizing](https://mitmath.github.io/18337/lecture2/optimizing)

From [https://github.com/mitmath/18337](https://github.com/mitmath/18337)

---

<div class="post-metadata">

### Author: ![rpmuller](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rpmuller/32/2262_2.png) [@rpmuller](https://discourse.julialang.org/u/rpmuller)
#### Post date: [May 8, 2021, 12:15am UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748/7 "2021-05-08T00:15:43Z")

</div>

> [@ChrisRackauckas](#):
>
> These days I’d recommend my lecture notes on serial code performance:

Excellent. Thanks!

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [May 8, 2021, 12:41am UTC](https://discourse.julialang.org/t/code-warntype-shows-lots-of-union-nothing-tuple-int64-int64/60748/8 "2021-05-08T00:41:35Z")

</div>

Are the other 6

1. Issue 265
2. higher order function performance
3. putting views on the stack
4. what are abstract types?
5. what are arrays?
6. how do we clone people named Chris?
