new Type[count] takes too much?
Namespace
rswhite4 at googlemail.com
Thu Oct 31 02:42:35 PDT 2013
On Thursday, 31 October 2013 at 09:27:11 UTC, bearophile wrote:
> Namespace:
>
>> T[] buffer = new T[N]; assumes more space than stated (in
>> average 2010 elements more. See:
>> http://dpaste.dzfl.pl/af92ad22c). It behaves exactly like
>> reserve and that is IMO wrong. If I reserve memory with
>> buffer.reserve(N), I want to have at least N elements. That
>> behaviour is correct. But if I use new T[N] I mostly want
>> exactly N elements and no extra space.
>>
>> Thoughts?
>
> In Python if you append items to an array, it sovra-allocates,
Never heard of 'sovra'. What does it mean?
> but if you create an array with the [x] * n syntax, then it
> creates a list (array) exactly of size n.
>
> Bye,
> bearophile
So you agree with me.
More information about the Digitalmars-d-learn
mailing list