[Python-ideas] Decimal literal?
Leif Walsh
leif.walsh at gmail.com
Thu Dec 4 21:18:03 CET 2008
Coming in to the thread _way_ late, here's my $0.015:
Sure, it would be great to have an accurate and fast implementation of
decimal/floating point numbers active by default in the language. We
don't have that yet. We have a fast implementation, and we have an
accurate one, and until we have both, there is a decision to be made:
which one is easy to use (in builtins, has literals, (etc.?)), and
which one is the "opt-in" implementation (needs a module import, needs
a constructor)?
We've been dealing with roughly the same fast and sometimes-inaccurate
floating-point implementation for what, almost 40 years of C
programming so far. Given that there exist accurate implementations
of decimal numbers (GMP, MAPM), why hasn't C moved to make one of
these the "default" implementation?
Whatever the answer, it seems to me that this sets a sort of precedent
in programming that fast floating-point numbers are favored over
accurate floating-point numbers. GMP is blindingly fast, and it isn't
C's default. Decimal is, I think I saw someone mention "hundreds of
times slower" than the current float implementation.
I think, until the decimal implementation approaches something like
GMP's speed, there really isn't much point in even considering making
it a default.
Now, to the question of a 'decimal literal': Including support for
something like '1.1d' requires that we include the decimal module in
builtins. Now, I don't know that there's no way around this, but it
seems like a slowdown for everyone just to let a few people type a bit
less. -1
--
Cheers,
Leif
More information about the Python-ideas
mailing list