<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Fun with generators</title>
	<link>http://efford.org/blog/archives/40</link>
	<description>Random musings on Python, software engineering, the web &#038; other stuff</description>
	<pubDate>Thu, 04 Dec 2008 00:57:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>

	<item>
		<title>by: fitzgeraldsteele</title>
		<link>http://efford.org/blog/archives/40#comment-32448</link>
		<pubDate>Fri, 25 Apr 2008 03:39:13 +0000</pubDate>
		<guid>http://efford.org/blog/archives/40#comment-32448</guid>
					<description>I had the same first impression of generators!  I had a similar 'aha' moment with generators in the last month or so.  I wanted to extend feedparser so that it would follow paging feeds.  My first implementation was a bit cludgy.  Then I took a couple hours to actually read about generators.  I ended up with much cleaner code, fewer lines, much less memory consumption, and a much more 'pythonic' interface to my pagingfeedparser. something like

for page in pagingfeedparser.parse():</description>
		<content:encoded><![CDATA[<p>I had the same first impression of generators!  I had a similar &#8216;aha&#8217; moment with generators in the last month or so.  I wanted to extend feedparser so that it would follow paging feeds.  My first implementation was a bit cludgy.  Then I took a couple hours to actually read about generators.  I ended up with much cleaner code, fewer lines, much less memory consumption, and a much more &#8216;pythonic&#8217; interface to my pagingfeedparser. something like</p>
<p>for page in pagingfeedparser.parse():
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Nick</title>
		<link>http://efford.org/blog/archives/40#comment-32419</link>
		<pubDate>Thu, 24 Apr 2008 18:46:07 +0000</pubDate>
		<guid>http://efford.org/blog/archives/40#comment-32419</guid>
					<description>Good point.  Memory use is thing that's always come top of my list when thinking of the potential benefits of generators.  David Beazley's post suggested other benefits that I hadn't really grokked - like the fact that a 'pipeline' approach leads to cleaner, much more readable code.</description>
		<content:encoded><![CDATA[<p>Good point.  Memory use is thing that&#8217;s always come top of my list when thinking of the potential benefits of generators.  David Beazley&#8217;s post suggested other benefits that I hadn&#8217;t really grokked - like the fact that a &#8216;pipeline&#8217; approach leads to cleaner, much more readable code.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jay P</title>
		<link>http://efford.org/blog/archives/40#comment-32402</link>
		<pubDate>Thu, 24 Apr 2008 15:11:09 +0000</pubDate>
		<guid>http://efford.org/blog/archives/40#comment-32402</guid>
					<description>One great use for generators is to save memory. I had a program once that would grind to a halt on older machines. Couldn't figure it out at first. Turned out I was using an iterator expression to build an ENORMOUS list, and then run through it.

Simply changed it to a generator expression, and suddenly it ran without eating all the machine's RAM. There was no point in building the list first, I just needed to iterate over the elements.</description>
		<content:encoded><![CDATA[<p>One great use for generators is to save memory. I had a program once that would grind to a halt on older machines. Couldn&#8217;t figure it out at first. Turned out I was using an iterator expression to build an ENORMOUS list, and then run through it.</p>
<p>Simply changed it to a generator expression, and suddenly it ran without eating all the machine&#8217;s RAM. There was no point in building the list first, I just needed to iterate over the elements.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
