[Python-3000] [Python-Dev] Rounding Decimals
python at rcn.com
Mon Jan 7 18:29:18 CET 2008
> I have always thought that "quantize()" makes Decimal
> confusing in the context of the other mechanisms that Python makes
> available for other kinds of numbers.
No doubt, the spec made a number of choices that are obvious only if you work at IBM. And, there is no doubt, the module has a high
level of complexity.
Jeffrey is proposing to add a Context.round() method with the purpose of making the module easier to use. I contend that this is
self-defeating on the face of it. Please count the number of existing Context methods (
http://docs.python.org/dev/library/decimal.html#context-objects ) and tell me that adding yet another method will reduce complexity
or shorten the learning curve. In fact, it will just further confuse which method should be used.
Also, I thought we were committed to a minimal implementation of the spec. One reason for this was that programs could be ported
back and forth with other implementations of the spec. Another reason is that the core spec has extensive test cases while
build-outs have none. And another reason is that we are trying to make life easier for someone (perhaps me) to rewrite the module in
There is also the principle of having only one way to do it. However, we already have Decimal.quantize and Context.quantize and are
about to introduce a number of magic methods callable from builtin functions. Do we really need even more ways to round? The
rounding operation is so fundamental to the module that user must grapple with it at some point. Having multiple ways to do it will
only make that task more difficult.
I spent about a month of my life cleaning, documenting, and testing the decimal module to get it ready for prime time. I'm not at
all pleased at the current proposal to add a duplicate method.
If someone really cared about making the module easier to use, I would fully support efforts to write a tutorial on the fundamentals
or an effort to write a client module implementing only a subset of the spec.
More information about the Python-3000