[BangPypers] Performance benefits of Generators?
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 -
> - Dhananjay is also on this list, so maybe he will also jump in with a
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.
> BangPypers mailing list
> BangPypers at python.org
Freenode: cornucopic in #scheme, #lisp, #math,#linux, #python
More information about the BangPypers