Perf penalty for function with return type of Union(Nullable{Union()}, Nullable{Float64})
#11699
Labels
missing data
Base.missing and related functionality
There's a substantial performance gap between (1) a function that returns either
Nullable{Union()}
orNullable{Float64}
depending on the input values and (2) a function that always returnsNullable{Float64}
for all input values. This isn't surprising to me, but it makes me concerned about usingNullable{Union()}
in performance critical code.Consider, for example, the following function for summing via direct addition of
Nullable
objects:Contrast that function with a function that has less type-uncertainty with regard to its return type:
It seems like there's a 30x perf penalty for using
Nullable{Union()}
. I imagine this is because everything inside of thesum
loop is boxed in case the type of the summands changes.Is there any way this could be improved? Or is it intrinsic to the non-concrete return type of the first definition of
+
?The text was updated successfully, but these errors were encountered: