[Python-ideas] Python Float Update
abarnert at yahoo.com
Tue Jun 2 14:50:42 CEST 2015
On Jun 2, 2015, at 05:44, random832 at fastmail.us wrote:
>> On Tue, Jun 2, 2015, at 08:34, Nick Coghlan wrote:
>> For decimal, the issues that keep it from becoming a literal are
>> similar to those that keep it from becoming a builtin: configurable
>> contexts are a core part of the decimal module's capabilities, and
>> making a builtin type context dependent causes various problems when
>> it comes to reasoning about a piece of code based on purely local
>> information. Those problems affect human readers regardless, but once
>> literals enter the mix, they affect all compile time processing as
> Why do contexts exist? Why isn't this an issue for float, despite
> floating point contexts being something that exists in IEEE 754?
The issue here isn't really binary vs. decimal, but rather that float implements a specific fixed-precision (binary) float type, and Decimal implements a configurable-precision (decimal) float type.
As Nick explained elsewhere in that message, decimal64 or decimal128 wouldn't have the context problem.
And similarly, a binary.Binary type designed like decimal.Decimal would have the context problem.
(This is a slight oversimplification; there's also the fact that Decimal implements the full set of 754-2008 context features, while float implements a subset of 754-1985 features, and even that only if the underlying C lib does so, and nobody ever uses them anyway.)
More information about the Python-ideas