On Sun, 16 Nov 2008 04:34:40 -0800, John Machin wrote: > Nothing to do with style. It was the screaming inefficiency of: > if non_trivial_condition: return x > if not non_trivial_condition: return y > that fired me up.
"Screaming inefficiency"? Try "micro-optimization". The difference in execution time between "if x... if not x..." versus "if x... else..." on my slow, underpowered machine is about 10**-8 seconds. If that's your idea of "screaming inefficiency" I can't understand why you're programming in Python in the first place. Of course, if x is an expensive function call (say, a network lookup or database query rather than a relatively cheap list indexing operation) then the more readable, Pythonic solution will also be significantly faster. There's no doubt that it should be preferred -- I'm not defending it, as such, just pointing out the over-reaction of dismissing what is a generally well-written and thought-out article on the basis of a triviality. >> http://en.wikipedia.org/wiki/Style_over_substance_fallacy > > Quoted Wikipedia -> instant disqualification -> you lose. Good night. Oh gosh, well, you've certainly proven your case, how could I be so stupid? My apology for thinking that you were acting like an arrogant, bad-tempered dick. I don't know *what* I was thinking. -- Steven who would link to Wikipedia for the definition of sarcasm except I've already lost once in this thread and that's enough. -- http://mail.python.org/mailman/listinfo/python-list