[Python-Dev] decimal API

Raymond Hettinger python at rcn.com
Tue Jul 6 11:14:45 CEST 2004

> Your list of ways that Decimal's model is better is an excellent
> list


Add one more.  The specs, the docs, the tutorial, and docstrings are
chock full of extensive examples.  Those examples include NaNs and
Infinities.  If the traps are all turned off by default, then the
examples fail.  That would suck.

I've spent weeks trying making sure the module integrates well with the
rest of Python.  To make the API choices as informed as possible, I
built some apps, wrote the docs (incl. docstrings, tutorial, and
whatsnew), communicated with Cowlishaw, communicated with the other
module authors, and read the after-the-fact usability reviews on Java's
big decimal package.  So, please, try out the module as-is and share the
results of your experience.

> So in the end, we're talking about what we want to do for people
> who choose NOT to read the docs.

People have been fond of quoting Tim lately.  I think either he or Guido
said that they are not persuaded by arguments that people are not bright
enough to get concepts like Infinity or NaN:

    >>> Decimal(1) / Decimal(0)

Not nearly as hard as descriptors, Unicode, half-open intervals, etc ;-)

> But if we left traps
> OFF then these foolish people might see that their program had
> run to completion and then accept the results without even
> realizing that there was a way to check for signals.

I'd like to think that wise people choose decimals over floats ;-)

More seriously, non-casual users of decimal *will* have to grapple with
the concept of contexts.  It is intrinsic to what the module is about.
It's not difficult, but it can't be avoided.  To that end, I introduced
contexts right away in tutorial and in the quick-start section of the


P.S.  Your reply address doesn't work for me.

More information about the Python-Dev mailing list