[Python-Dev] Mixing float and Decimal -- thread reboot

Glenn Linderman v+python at g.nevcal.com
Wed Mar 24 23:09:29 CET 2010


On 3/24/2010 1:56 PM, Raymond Hettinger wrote:
> FWIW, my viewpoint on this is softening over time
> and I no longer feel a need to push for a new context flag.
>    


To make Decimal useful for people that want to control its numerical 
quality, there must be a way to exclude accidental operations, and 
preferably an option for producing exceptions.  Otherwise the status quo 
in 3.x is preferable to adding it to the numeric tree.

I agree that not worrying can make you feel better, though. :)


> IIRC, the original purpose of a NaN was to serve as a placeholder
> value in a long series of floating point ops so that the programmer
> would not have to introduce edge case tests at each stage
> of a calculation.  Yet, I look at the code for the decimal module
> and the C code for the math module and see that the opposite
> result occurred, the code is littered with is_special(x) tests
> and handlers.

You are looking at the wrong code.  The point is that the code _using_ 
the math module and decimal module doesn't have to be littered with edge 
case tests; not that the implementation, which the good folks at IEEE 
figured would be in custom silicon that could do the edge case checking 
in parallel with other operations and with no net slowdown, would not 
have to be littered with edge cases.


Glenn


More information about the Python-Dev mailing list