
Facundo writes:
Here are my thoughts, just as untutored as yours. I'm working primarily from hursley's spec here... Signal Should it raise by default? And why? ------ ------------------------------------ Clamped Yes - well, maybe. When could we ever generate this? ConversionSyntax Yes - it prevents lots of possible user errors DivisionByZero Yes - other numeric types raise for this in Python DivisionImpossible Yes - I don't fully understand it but it seems bad DivisionUndefined Yes - other numeric types raise for this in Python Inexact No - this is perfectly normal InsufficientStorage N/A - this doesn't exist in the Python implementation InvalidContext Yes - I don't understand how this could happen, but surely we should complain about it, right? InvalidOperation Yes - Users want exceptions when doing invalid math Overflow Yes - overflows lose data, so we should raise Rounded No - this is perfectly normal Subnormal No - this is perfectly normal (subnormal?) Underflow No - since Inexact, Rounded, and Subnormal are all unreported, this should be also! Then there are these, which I don't recognize: DecimalException, LostDigits To sum things up, I would suggest that *by default* errors should never pass silently, and that "errors" is defined as broadly as possible without triggering on normal arithmatic. Obviously, it's easy to change the settings, but it's much easier to DISABLE an exception when your program starts generating it, than to ENABLE it, because if it's disabled, you don't necessarily know that it is happening. Besides, it seems Pythonic to be pedantic. -- Michael Chermside

[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
participants (2)
-
mcherm2@mcherm.com
-
Raymond Hettinger