[Python-ideas] Aid reiteration with new class: gfic
Steven D'Aprano
steve at pearwood.info
Sat Jun 20 11:24:12 CEST 2009
On Sat, 20 Jun 2009 01:55:42 pm John Graham wrote:
> Hrm, that leads to the question, is it mathematically possible to
> iterate over an infinite list... twice? :)
Mathematically, yes. Practically, no.
Mathematically, the trick is to ensure that the time it takes to iterate
over each item approaches zero sufficiently fast. E.g. if it takes 1
unit of time to process the first item, and 1/2 units of time for the
second, and 1/4 for the third, 1/8 for the fourth, etc, then you can
iterate over an infinite number of items in 2 units of time total. Then
you can do them all again :)
--
Steven D'Aprano
More information about the Python-ideas
mailing list