Rules when box/unbox applies

Yes! E.g. @code_warntype my_test() (you can call it on any julia expression). Everything printed in red is “bad” (not concretely typed).

Edit: I should amend to say two things:

  1. Tools like ProfileView.jl are useful for this also, as they highlight type instabilities in the stack with a red color.
  2. Type instability is not inherently bad, and can be just fine if used judiciously. What there isn’t a tool for examining is whether a function is “easy for the compiler” or “hard for the compiler”. That sort of functionality might exist some day, but at the moment it doesn’t
3 Likes