Maybe this is just a curiosity, but I once wrote a function that is intentionally type unstable, in order to get better performance. The function in question is testzero from the module Zeros.jl. It returns different types depending on if the input is zero.
If I have a function f(a,b) which can be simplified in the special case of a equal to zero, and I know that there’s a high likelihood that a will in fact be zero, then I can call f(testzero(a),b) which will call a version of f that has been specifically compiled for a=0 if that is the case.
(It is possible that writing an explicit branch would be faster than relying on dynamic dispatch when there are only two methods to choose from - I haven’t tried. But if so, then I’m confident that Julia will make that optimization eventually.)