If you expect that you're going to have to push a lot of values onto a
vector, you can avoid the cost of incremental reallocation by doing it once
up front.

On Wednesday, October 21, 2015, Jacob Quinn <quinn.jac...@gmail.com> wrote:

> The way I came to understand was to just take a peak at the [source code](
> https://github.com/JuliaLang/julia/blob/ae154d076a6ae75bfdb9a0a377a6a5f9b0e1096f/src/array.c#L670);
> I find it pretty legible. The basic idea is that the underlying "storage"
> of a Julia Array{T,N} can actually be (and often is) different than the
> size(A) in Julia. sizehint! modifies that underlying storage without
> changing the size(A) in Julia.
>
> -Jacob
>
> On Wed, Oct 21, 2015 at 12:46 PM, Seth <catch...@bromberger.com
> <javascript:_e(%7B%7D,'cvml','catch...@bromberger.com');>> wrote:
>
>> I know it's good to use sizehint! with an estimate of the sizes of
>> (variable-length) containers such as vectors, but I have a couple of
>> questions I'm hoping someone could answer:
>>
>> 1) what are the benefits of using sizehint!? (How does it work, and under
>> what circumstances is it beneficial?)
>> 2) what are the implications (positive/negative, if any) of
>> overestimating the size of a container?
>>
>> Thanks.
>>
>
>

Reply via email to