Closed
Description
Broadcasting with boolean operators seems to be very slow in some circumstances:
See below one example with Julia 1.8.2:
julia> x = randn((100,));
julia> y = randn((1,100));
julia> @time (x.^2 .< 1) .&& (1 .+ y.^2 .<1);
0.004369 seconds (144.73 k allocations: 3.005 MiB)
julia> @btime ($x.^2 .< 1) .&& (1 .+ $y.^2 .<1);
4.009 ms (144713 allocations: 3.00 MiB)
# this works
julia> @btime ($x.^2 .< 1) .&& ($y.^2 .<1);
2.523 μs (3 allocations: 5.56 KiB)
julia> @btime ($x.^2 .< 1) .|| ($y.^2 .+ 1 .<1);
2.738 μs (3 allocations: 5.56 KiB)