On Tue, Jun 30, 2009 at 3:37 PM, Amit Saha <[email protected]> wrote:
> > > > > Theoretically and/or practically, is it possible to reason about the > > performance gain/loss of using generators? The PEP 255 > > (http://www.python.org/dev/peps/pep-0255/) doesn't seem to hint at it. > > Since, this is out of mere curiosity, for the moment, performance > would be simply the time taken to complete a task. > Check out David Beazley's(dabeaz) article on Generators. OTOH, Decorators , lambdas ('syntactic sugars') et al reduce the number of lines of code, depending on the scenario, for a given piece of complex logic, but these are 'slow'. But, I dont think the factor is huge enough to cause a performance bottleneck. I had similar reservations on list comprehensions, but in some cases the bytecode generated by LC is same as the one generated by the if-else/loop counterparts. If you are building apps wherein every microsecond matters, then it is better to time both variants - the sugars and their vanilla equivalents - and then choose the best. -V- http://twitter.com/venkasub
_______________________________________________ BangPypers mailing list [email protected] http://mail.python.org/mailman/listinfo/bangpypers
