[Python-ideas] Python Numbers as Human Concept Decimal System

Antoine Pitrou solipsis at pitrou.net
Tue Mar 11 18:43:28 CET 2014


On Tue, 11 Mar 2014 17:03:01 +0000
Oscar Benjamin
<oscar.j.benjamin at gmail.com> wrote:
> 
> The issue is bigger than constant folding. The problem is about being
> able to understand a simple looking expression or block of code. With
> the decimal module it becomes necessary to consider many different
> cases. What if the precision is less than X or higher than Y? What if
> this particular Decimal has a precision exceeding that of the current
> context?

Many APIs have context-dependent meaning, especially in a duck-typed
languages such as Python. I don't think decimals are a special-case
here.

OTOH, *if you know that d and e are decimals*, then what e.g. `d + e`
does is pretty clear, regardless of the context. Knowing the precision
isn't necessary for *understanding* what the code does; it may be
necessary to track an unexpectedly "wrong" result, but that's all.

And, besides, I think much of this argument is based on FUD. Probably
in most real-world situations people don't set the decimal context to
some arbitrarily low precision, so I don't know what the *practical*
problem is.

> The issue applies to all programmers but consider the case where an
> inexperienced user posts code that doesn't work asking for help.

Define "doesn't work". If the stated result simply isn't precise
enough (or is too precise for the user's expectation), then it will be
obvious what the cause is! No need for some heroic spelunking here,
AFAICT.

Regards

Antoine.




More information about the Python-ideas mailing list