Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is absolutely true—I was just putting them everywhere possible in an attempt to avoid allocations.


I don’t know much about Julia, why would it potentially cause allocations?


if 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.


Thank 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


Yeah this is a minor gripe with Julia. It has type inference but it's risky to use.


True, 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: