how to make a generator use the last yielded value when it regains control

Lonnie Princehouse finite.automaton at gmail.com
Mon Apr 10 13:33:30 EDT 2006


In general, you're right - if speed is a concern, loops should be used
instead of recursion in Python when possible.

In this case, the recursive overhead is insignificant compared to the
expense of iterating over the sequence at every iteration.  By the time
there are 70 stack frames of recursion (i.e. not much), the sequence is
more than 170 million elements long.




More information about the Python-list mailing list