Alex Popescu wrote: > On Jul 14, 5:55 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> So, as always, one should measure in each specific case if optimization is >> worth the pain [...]. >> > > I hope I am somehow misreading the above sentence :-). IMO synonim > language contructs > should result in the same performance or at least have clear/ > documented performance.
That's a fine opinion, how would you enforce it? Should we go throught he interpreter slowing down the faster to each pair of alternative constructs? ;-) It's inevitable there'll be differences in execution time between equivalent constructs, and in that case you have to test to find the better in your specific situation. The real issue here is that in 95% or more of the source of most programs speed/performance isn't that much of an issue anyway. > I don't think we really want to see in code something like: > > if threshold: > do_it_with_list_function > else: > do_it_with_list_comprehension > This would most certainly be a premature optimization which, as has been repeated many times on this list, is the root of much evil in programming. As Gabriel mentioned, you only need to do it if it's "worth the pain", which in most case it won't be. It isn't worth spending even five minutes to shave a minute off the performance of a ten-minute program that is only run once a week, for example. Ultimately we have to be pragmatic: circumstances alter cases, and it's usually not worth spending the time to improve execution speed except for the most critical parts (the innermost nested loops) of production programs. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- http://mail.python.org/mailman/listinfo/python-list