Interesting list() un-optimization
tjreedy at udel.edu
Thu Mar 7 21:34:33 CET 2013
On 3/7/2013 11:20 AM, Christian Heimes wrote:
> But iterators have a length hint method that are used for some
> optimizations and preallocations, too.
This is easy when the base iterable has a length method, as do range
>>>> i = iter(range(10))
And the length_hint can (should be) decremented with each next call.
>>> next(i); next(i)
Terry Jan Reedy
More information about the Python-list