[Python-ideas] Python Numbers as Human Concept Decimal System

Stefan Krah stefan at bytereef.org
Tue Mar 11 21:53:31 CET 2014


Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:
> >> On Tue, Mar 11, 2014, at 14:41, Stefan Krah wrote:
> >> >   1) It must be possible to set rounding and traps, so the context
> >> >      is not really fixed.
> >>
> >> It _must_ be possible? If there's a way to set rounding for floats, I
> >> can't find it. As for traps, I can't find that either, but a constant
> >> operation that may (will?) trap disables constant-folding.
> >
> > If we use IEEE, the default context would not raise anything -- infinities
> > and NaNs would silently propagate.  This is valuable, but it should be
> > possible switch it off.  Settting rounding is obviously valuable, too.
> 
> I was intending that it would be possible to use the traps and flags
> on this context. Perhaps Stefan knows something I don't but I thought
> that the constant folder could just use a hyper-sensitive context and
> check for exceptions (or otherwise check the flags). I assumed this is
> how it handled cases like '1 / 0' and '1.0 * 10 ** 1000' which are not
> folded so that they can raise exceptions at the appropriate time.

I meant that an external package that modifies e.g. rounding in the global
context would also affect results, so the problem (which was used as an
argument in favor of the fixed width decimal) is not limited to exponents
and precision.


Stefan Krah




More information about the Python-ideas mailing list