[Python-ideas] Floating point contexts in Python core
Oscar Benjamin
oscar.j.benjamin at gmail.com
Thu Oct 11 10:56:31 CEST 2012
On 11 October 2012 06:45, Greg Ewing <greg.ewing at canterbury.ac.nz> 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.
>
> It might make sense for them to share whatever parts of the
> fp context apply to both, and they might have a common base
> type, but they should probably remain distinct types with
> separate implementations.
This is what I was pitching at. It would be great if a single floating
point context could be used to control the behaviour of float,
decimal, ndarray etc simultaneously.
Something that would have made my life easier yesterday would have
been a way to enter a debugger at the point when a first NaN is
created during execution. Something like:
python -m pdb --error-nan broken_script.py
Or perhaps:
PYTHONRUNFIRST='import errornan' python broken_script.py
With numpy you can already do:
export PYTHONRUNFIRST='imoprt numpy; numpy.seterr(all='raise')'
(Except that PYTHONRUNFIRST isn't implemented yet:
http://bugs.python.org/issue14803)
Oscar
More information about the Python-ideas
mailing list