count items in generator
Delaney, Timothy (Tim)
tdelaney at avaya.com
Sun May 14 18:37:21 EDT 2006
George Sakkis wrote:
> Paul Rubin wrote:
>
>> claird at lairds.us (Cameron Laird) writes:
>>> For that matter, would it be an advantage for len() to operate
>>> on iterables?
>>
>> print len(itertools.count())
>>
>> Ouch!!
>
> How is this worse than list(itertools.count()) ?
list(itertools.count()) will eventually fail with a MemoryError.
Actually len(itertools.count()) would as well - when a couple of long
instances used up everything available - but it would take a *lot*
longer.
Tim Delaney
More information about the Python-list
mailing list