Is map(f,collection) memory inefficient?

Please ignore. Didn’t realize the 2x will be a UInt and not UInt8.

julia> @benchmark map(x -> UInt8(2x), $arr)
BenchmarkTools.Trial: 
  memory estimate:  1.00 MiB
  allocs estimate:  3
  --------------
  minimum time:     936.873 μs (0.00% GC)
  median time:      951.316 μs (0.00% GC)
  mean time:        978.969 μs (1.52% GC)
  maximum time:     1.825 ms (0.00% GC)
  --------------
  samples:          5101
  evals/sample:     1

This fixes the issue.

1 Like