Since it hasn't been mentioned yet, I'll point out `sizehint!` which can 
eliminate the re-allocations. But this is still slower than setting the 
elements, because it needs to update the length of the array on each `push!`.

Worth benchmarking yourself if it matters to how you design your code.

Best,
--Tim

On Tuesday, May 10, 2016 01:24:28 PM Andrei Zh wrote:
> From performance perspective, how bad it is to use `push!(array, element)`
> compared to pre-allocating array and setting elements in it?
> 
> More generally, how extending arrays works in Julia? (code in array.c
> <https://github.com/JuliaLang/julia/blob/master/src/array.c> is quite
> readable, but some high-level description is appreciated)

Reply via email to