<div class="gmail_quote">On Tue, Jun 30, 2009 at 3:36 PM, Amit Saha <span dir="ltr">&lt;<a href="http://amitsaha.in">amitsaha.in</a>@<a href="http://gmail.com">gmail.com</a>&gt;</span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Theoretically and/or practically, is it possible to reason about the<br>
performance gain/loss of using generators?  The PEP 255<br>
(<a href="http://www.python.org/dev/peps/pep-0255/" target="_blank">http://www.python.org/dev/peps/pep-0255/</a>) doesn&#39;t seem to hint at it.<br>
<br>
Anything that any of you would like to share on this ?<br></blockquote></div><br><div>The most prevalent use case is in designs where a list generated by a function is iterated over (third para of the PEP). Other couple of places where I have used them are for tree traversal (instead of recursion), and as generator expressions (instead of list comprehensions).</div>
<div><br></div><div>In all these three scenarios generators provide both CPU and memory improvements over the traditional solutions.</div>