<p><br>
On Jul 16, 2012 1:52 PM, &quot;Stephen J. Turnbull&quot; &lt;<a href="mailto:stephen@xemacs.org">stephen@xemacs.org</a>&gt; wrote:<br>
&gt; The point is that I don&#39;t really see the value in returning a precise<br>
&gt; estimate that cannot be relied on to be accurate.  OK, Python is a<br>
&gt; &quot;consenting adults&quot; language, but returning an integer here seems like<br>
&gt; invitation to abuse. </p>
<p>Because preallocating memory is ridiculously faster than doing multiple resizes. That&#39;s all this API is for: how many objects should a container constructor preallocate space for when building from an iterable. It&#39;s an important optimisation in CPython when using itertools, and PyPy is planning to adopt it as well. Alex is doing the right thing in attempting to standardise it rather than risk the two implementations using subtly incompatible definitions. </p>

<p>Skipping the iteration in the zero case is a pointless micro-optimisation that just makes the API more complex for no good reason. Allowing a negative hint to mean &quot;infinite&quot;, on the other hand, avoids certain categories of errors without making the API any harder to use (since negatives have to be rejected anyway).</p>

<p>--<br>
Sent from my phone, thus the relative brevity :) <br>
</p>