[Python-Dev] decimal API

Raymond Hettinger python at rcn.com
Tue Jul 6 06:55:25 CEST 2004


[Michael]
> Here are my thoughts, just as untutored as yours. I'm working
> primarily from hursley's spec here...

For the alpha, I've left all of the traps off except for
ConversionSyntax.  The reasoning that the numeric model is otherwise
self-contained.  Dividing by zero usefully gives Infinity.  NaNs result
from non-sensical operations.  NaNs can even have diagnositic
information associated with them.  Let's let people experience what the
standard has to offer.

By way of comparison, look at MS Excel.  Rather than bomb-out, it has
values such as N/A and #DIV/0 which are all part of the model and flow
through calculations if necessary.

Though decimals play nice with many other Python tools, we shouldn't
hide that the model is different and that many of those differences are
for the better:

- Calculations taking place within a user settable context
- Special values such as NaNs and Infinities
- Negative zero
- Signals can be ignored, inspected (flag), or raised (trapped)
- Notion of significance:   1.25 + 1.75 --> 3.00 with two trailing
zeroes



Raymond



More information about the Python-Dev mailing list