Inference time

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

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’?

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:

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