Understanding and avoiding allocations with StructArrays

Quick update: this seems to be fixed in v1.6#master:

ntup = (a=rand(Int, 1000), b=rand(Float64, 1000))

function f(ntup,field,i,val)
       ntup[field][i] = val
       return
end

@btime f($ntup, :a, 1, 1)
# 1.595 ns (0 allocations: 0 bytes)
1 Like