[Python-ideas] Settable defaulting to decimal instead of float

Nick Coghlan ncoghlan at gmail.com
Thu Jan 12 07:07:52 EST 2017


On 12 January 2017 at 20:30, Paul Moore <p.f.moore at gmail.com> wrote:
> It's unlikely that there's a practical suggestion here that hasn't
> been discussed before and rejected

There's one practical decimal-literal-related suggestion which hasn't
been rejected yet: adding a true decimal literal based on decimal128
semantics *without* configurable context support (so compile time
constant folding can work normally rather than all operations needing
to be deferred to runtime).

Folks that wanted to fiddle with the context settings would still need
to use decimal.Decimal objects, but there'd also be a readily
available builtin base10 counterpart to the binary "float" type.

As far as I know the main barrier to that approach is simply the lack
of folks with the time, interest, and expertise needed to implement,
review, and document it, rather than it being an objectionable
proposal at the language design level. (There would be some concerns
around potential confusion between when to use the default binary
literals and when to use the decimal literals, but those concerns
arise anyway - the discrepancies between binary and decimal arithmetic
are just one of those unfortunate facts of computing at this point)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list