[Python-ideas] Floating point contexts in Python core
steve at pearwood.info
Thu Oct 11 13:35:28 CEST 2012
On 11/10/12 16:45, Greg Ewing wrote:
> Alexander Belopolsky wrote:
>> I gave this idea +float('inf') in the other thread and was thinking about it
>> since. I am now toying with the idea to unify float and decimal in Python.
> Are you sure there would be any point in this? People who
> specifically *want* base-2 floats are probably quite happy
> with the current float type, and wouldn't appreciate having
> it slowed down, even by a small amount.
I would gladly give up a small amount of speed for better control
over floats, such as whether 1/0.0 raised an exception or
If I wanted fast code, I'd be using C. I'm happy with *fast enough*.
For example, 1/0.0 in a continued fraction is generally harmless,
provided it returns infinity. If it raises an exception, you have
to write slow, ugly code to evaluate continued fractions robustly.
I wouldn't expect 1/0.0 -> infinity to becomes the default, but
I'd like a runtime switch to turn it on and off as needed.
More information about the Python-ideas