On Thu, Feb 10, 2011 at 12:01 PM, Terry Reedy <tjre...@udel.edu> wrote:
> On 2/10/2011 11:52 AM, Ethan Furman wrote: > > Jason Swails wrote: >> > > > How is "while n != 0:" any worse? >>> >> > 1. It is redundant, just like 'if bool_value is not False:'. > Python programmers should understand the null value idiom. > > 2. It does 2 comparisons, 1 unneeded, instead of 1. For CPython, > it adds 2 unnecessary bytecode instructions and takes longer. > I see what you mean, and I think we're coming from different perspectives. First I must say that the calculations I implement/use are VERY computationally demanding and code optimization is of utmost importance, so this point does not fall on deaf ears. I agree that code optimization can be very important. However, the only things worth *optimizing*, really, is the RDS. Optimizing parts of the program that consume ~5% of the total operation time to run ~20% faster is only ~ 0.1% increase in total performance -- a sacrifice I'm more than willing to make for code readability (as a general philosophy). These programs are also very large, collaborative efforts that necessarily have many people working on it, modifying it, etc. It's this reason why I say that sometimes code readability trumps performance. > It has exactly the same effect without adding any code >>> >> > Untrue, see above. > What I meant was that the function result is unchanged without adding more LOC; not that it was the same on the instruction level. I think this is just a difference of perspective: mine is almost strictly utilitarian, in that I just use languages/code/computers to solve my problems. All the best, Jason > > > -- > Terry Jan Reedy > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Graduate Student 352-392-4032
-- http://mail.python.org/mailman/listinfo/python-list