[Python-Dev] Adventures with Decimal

Raymond Hettinger python at rcn.com
Fri May 20 22:52:22 CEST 2005


> Does it really need to be argued interminably that deviating from a
> standard is a Big Deal? 

The word deviate inaccurately suggests that we do not have a compliant
method which, of course, we do.  There are two methods, one context
aware and the other context free.  The proposal is to change the
behavior of the context free version, treat it as a bug, and alter it in
the middle of a major release.  The sole argument resembles bible
thumping.

Now for a tale.  Once upon a time, one typed the literal 1.1 but ended
up with the nearest representable value, 1.1000000000000001.  The
representation error monster terrorized the land and there was much
sadness. 

>From the mists of Argentina, a Palidan set things right.  The literal
1.1 became representable and throughout the land the monster was
believed to have been slain.  With their guard down, no one thought
twice when a Zope sorcerer had the bright idea that long literals like
1.1000000000000001 should no longer be representable and should
implicitly jump to the nearest representable value, 1.1.  Thus the
monster arose like a Phoenix.  Because it was done in a bugfix release,
without a PEP, and no public comment, the citizens were caught
unprepared and faced an eternity dealing with the monster so valiantly
assailed by the Argentine.

Bible thumping notwithstanding, this change is both unnecessary and
undesirable.  Implicit rounding in the face of explicit user input to
the contrary is a bad idea.  Internally, the implementation relies on
the existing behavior so it is not easily changed.  Don't do it.



Raymond


More information about the Python-Dev mailing list