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 objects.
i = iter(range(10)) i.__length_hint__()10
And the length_hint can (should be) decremented with each next call. >>> next(i); next(i) 0 1 >>> i.__length_hint__() 8 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list