4 ms·
This is absolutely true—I was just putting them everywhere possible in an attempt to avoid allocations.
by juliusgeo 4y ago
This is absolutely true—I was just putting them everywhere possible in an attempt to avoid allocations.
- cmovq 4y agoI don’t know much about Julia, why would it potentially cause allocations?
- adgjlsfhk1 4y agoif the code was type unstable that can cause allocations, but in cases like this it wouldn't. Type instability is the ability of the compiler to predict the types of variables from the types of the inputs. Type unstable code can be found using `@code_warntype` and will cause allocations do to boxing and dynamic dispatch.
- juliusgeo 4y agoThank you for the feedback. I will try to remove as many of the explicit type hints as possible. The main reason I added them everywhere is because I found sometimes there would be instability at super low decimal ranges because of type promotion
- xmcqdpt2 4y agoYeah this is a minor gripe with Julia. It has type inference but it's risky to use.
- andyferris 4y agoTrue, but you can remove a lot of the risk by inspecting the results of type inference with `@code_warntype` in places where you suspect it might be not be working. I believe JET.jl can automate global program analysis, but I haven't used it.