[BangPypers] Performance benefits of Generators?

Amit Saha amitsaha.in at gmail.com
Sat Jul 4 05:59:39 CEST 2009

On Sat, Jul 4, 2009 at 9:24 AM, Navin Kabra<navin.kabra at gmail.com> wrote:
>> 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.
> I'm wondering: if you are building apps wherein every microsecond
> matters, why are you doing it in Python? Python is bound to be about
> 10x slower than Java/C/C++ so for apps where performance is so
> important, you're better off writing in those languages. Or, better
> still, just replace the important parts with native C code. Python
> code should focus on what python is good at - readability,
> conciseness, maintainability. Leave the performance aspects to
> languages that are better at it.
> (Reference for the 10x slower comment -
> http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/
> - Dhananjay is also on this list, so maybe he will also jump in with a
> response)

No not yet. I am not building a application where every mu-sec
matters. I appreciate the link and comments though. Will be helpful
some day in the future.


> navin.
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers

Journal: http://amitksaha.wordpress.com,
µ-blog: http://twitter.com/amitsaha

Freenode: cornucopic in #scheme, #lisp, #math,#linux, #python

More information about the BangPypers mailing list