Be less aware of when Julia avoids specializing?

+1

Or at least having much more sensible defaults given the current state of Julia precompilation and package extensions. I could see having a larger upper bound for Vararg non-specialization be an easy improvement. Right now it seems too extreme imo:

julia> f(x...) = x

julia> Base.specializations(@which f(1, 2))
Base.MethodSpecializations(MethodInstance for f(::Int64, ::Vararg{Int64}))

which is not great when, as you mention, it’s often encouraged to write generic code without worrying about lost performance.

Also worth noting that the Vararg specialization rules are currently so complicated they seem to result in unexpected behavior when you combine them with other non-specializing types:

I think simpler rules would generally be better if the specialization behavior is changed.

1 Like