# Inference time

**URL:** <https://discourse.julialang.org/t/inference-time/41191>\
**Category:** General Usage\
**Created:** [June 11, 2020, 9:41am UTC](https://discourse.julialang.org/t/inference-time/41191 "2020-06-11T09:41:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maarten\_van\_damme](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maarten_van_damme/32/6946_2.png) [@maarten\_van\_damme](https://discourse.julialang.org/u/maarten_van_damme)\
**Post date:** [June 11, 2020, 9:41am UTC](https://discourse.julialang.org/t/inference-time/41191/1 "2020-06-11T09:41:15Z")

</div>

Frequently I have run into problems with extremely long inference times, and those kind of issues are really difficult to debug (I have one right now)

Is there a flag that will make julia just give up as soon as possible on inference? If I’m developing code I don’t mind having to wait a few seconds for every function call, if that means that I don’t have to wait a ridiculous amount of time everytime I restart my julia session.

Are there best practices? For example, lets say I have a custom type testarr{E}, for which I know that getindex will return something of type E, but this can’t be apparant to the julia inference algorithm, can I just define

```julia
toret::E = nontrivial_calculation()

```

and have julia inference just skip having to infer the nontrivial calculation? Is there any non-trivial information out there other then ‘don’t use globals’?

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [June 11, 2020, 12:58pm UTC](https://discourse.julialang.org/t/inference-time/41191/2 "2020-06-11T12:58:48Z")

</div>

Did you try specifying a return type for the function? I’m not sure that would stop all inference but Julia should be able to just look at the function see that it’s returning E and move on. So with your get index example it would be:

```julia
getindex(a::testarr{E}, i)::E where E = # code here.

```
