IF...ELSEIF...ELSE performance

I think a few high-level lessons can be gleaned from this thread:

  1. Dicts are impressively fast.
  2. What LLVM does with an if/else nest is opaque and unpredictable. If that’s the only way to express your computation, so be it, but if there’s a more structured way, you’re probably better off preserving and exposing the structure.
  3. Tuples really rule for performance.

To a large extent, tuples exist to hint to the compiler that it should reason about the individual types and number of elements in an immutable collection. Otherwise we’d just use Vector{Any}—but that type serves as a hint of precisely the opposite: it tells the compiler not to worry about how many or what the specific types in a collection are.

7 Likes