The following two functions seem to do exactly the same thing, but the built-in version (
randn!) is some 60% slower. Am I missing something or could
randn! be implemented more efficiently?
using Random broadcast_randn(x) = (x .= randn.()) inplace_randn(x) = randn!(x) x = zeros(10_000) @btime broadcast_randn($x) 41.680 μs (0 allocations: 0 bytes) @btime inplace_randn($x) 68.003 μs (0 allocations: 0 bytes)