[Python-Dev] [Python-checkins] r68182 - in python/trunk: Lib/decimal.py Misc/NEWS

Mark Dickinson dickinsm at gmail.com
Tue Jan 6 11:26:13 CET 2009


On Mon, Jan 5, 2009 at 3:12 PM, Jim Jewett <jimjjewett at gmail.com> wrote:
> Our of curiousity, why are these constants for internal use only?

I don't think anyone ever thought about deliberately making them
public---I suspect they were introduced as a speed optimization.

I can see that having things like NaN = Decimal('NaN') might be
handy for some users (though I actually suspect that the
intersection between Decimal users and those who care about
NaNs is rather small...), but they don't belong in the decimal
module, which is supposed to be kept very close to the standard
and, exactly as you say, keep the beyond-the-spec API small.

Maybe it's time for the "Add a decimal_utils module" PEP,
which could contain such constants?  There are many
other definitions and conveniences that could go into such a module.
One thing in particular that I miss is a sqrt() *function* (as
opposed to Decimal method) that takes a Decimal, int or long
and returns a Decimal;  similarly for exp, log, log10, ...
Another thing that has been requested recently on c.l.p.
is good implementations of trig functions for Decimal, which
are quite hard to do properly.

Mark


More information about the Python-Dev mailing list