I’m not a dev, but one factor to consider is that if
foo(x) contains a call to
f(y), and the type of
y is inferred, then the compiler will recursively perform inference (but not specialization) on
f. As long as
f(y) is going to be called, that’s fine, but if
f(y) is in a never-executed branch of an
if, then that’s wasted computation. Thus: type stability might (at least theoretically) lengthen compilation time, especially if you have deep parametric types.
Or perhaps that’s a marginal concern. I don’t know. We’re lacking tools to measure where compilation time is happening. My code takes minutes to compile so I share your pain. I’m currently working on a package to expose
Base.Profile's data. Presumably, we could take the difference between a warm run and a cold run to produce a report on compilation time, but the details are tricky. Any suggestion welcome.