Just noticed, the MWE
using Random
using BenchmarkTools
Random.seed!(42)
array = rand(1_000_000)
x = @btime sum([y*y for y in $array])
z = @btime sum(y*y for y in $array)
@show x
@show z
@assert z == x
yields (obviously?)
1.810 ms (2 allocations: 7.63 MiB)
1.006 ms (0 allocations: 0 bytes)
x = 332909.22931042255
z = 332909.2293104364
ERROR: AssertionError: z == x
so Julia doesn’t always use pairwise sum?
Edit: noticed this analyzing @TouchSir’s posting.