Union{Missing, T}
is not 100% as fast as just using T
, causes more allocations, and is not compatible with C code:
julia> struct Foo
x::Int
end
julia> struct FooM
x::Union{Missing,Int}
end
julia> function fillfoo(T,n)
ret = Array{T}(undef, n)
for k = 1:n
ret[k] = T(1)
ret
end
end
julia> @time fillfoo(Foo, 100000);
0.046550 seconds (199.50 k allocations: 3.808 MiB)
julia> @time fillfoo(FooM, 100000);
0.049624 seconds (299.50 k allocations: 8.385 MiB)