Use of generators and efficiency
python.list at tim.thechases.com
Wed Sep 17 13:21:19 CEST 2008
> To my great surprise, this approach was often considerably _slower_ to
> complete than the original program (up to ~40% depending on which modifiers
> were used), despite producing initial results more quickly.
You may be interested in reading through this thread
where looping vs generators were timed and you can see that
generators clearly (and sadly) impose a speed penalty as
demonstrated by Andrew Reedick. I'm not sure whether the "why"
of it was ever determined, but generators should be used with
care if speed is more important than clarity.
More information about the Python-list