+1 for removing constant folding for floats (besides conversion
of -<literal>).  There are just too many things to worry about:
FPU rounding mode and precision, floating-point signals and flags,
effect of compiler flags, and the potential benefit seems small.

If you're talking about the existing peepholer optimization that
has been in-place for years, I think it would be better to leave
it as-is.  It's better to have the compiler do the work than to
have a programmer thinking he/she needs to do it by hand
(reducing readability by introducing magic numbers).
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.

The list of "things to worry about" seems like the normal list
of issues associated with doing anything in floating point.
Python is already FPU challenged in that it offers nearly
zero control over the FPU or direct access to signals and flags.
Every step of a floating point calculation in Python gets written-out to a PyFloat object and is squeezed back into a C double (potentially
introducing double-rounding if extended precision had be used by
the FPU).  Disabling the peepholer doesn't change this situation.


Raymond
_______________________________________________
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

Reply via email to