On Mon, Apr 6, 2009 at 9:05 PM, Raymond Hettinger <pyt...@rcn.com> wrote: > The code for the lsum() recipe is more readable with a line like: > > exp = long(mant * 2.0 ** 53) > > than with > > exp = long(mant * 9007199254740992.0) > > It would be ashamed if code written like the former suddenly > started doing the exponentation in the inner-loop or if the code > got rewritten by hand as shown.
Well, I'd say that the obvious solution here is to compute the constant 2.0**53 just once, somewhere outside the inner loop. In any case, that value would probably be better written as 2.0**DBL_MANT_DIG (or something similar). As Antoine reported, the constant-folding caused quite a confusing bug report (issue #5593): the problem (when we eventually tracked it down) was that the folded constant was in a .pyc file, and so wasn't updated when the compiler flags changed. Mark _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com