Why does broadcast operation allocate?

It doesn’t:

julia> a = rand(241); b = rand(241);

julia> function minuseq!(a,b)
           a .-= b
           nothing
       end
minuseq! (generic function with 1 method)

julia> @time minuseq!(a,b)
  0.046553 seconds (196.53 k allocations: 11.362 MiB, 99.96% compilation time)

julia> @time minuseq!(a,b)
  0.000003 seconds
1 Like