[Python-ideas] float vs decimal
wilk at flibuste.net
Wed Mar 11 22:32:10 CET 2009
On 11-03-2009, Chris Rebert wrote:
> On Wed, Mar 11, 2009 at 12:25 PM, William Dode <wilk at flibuste.net> wrote:
>> I just read the blog post of gvr :
>> And i wonder why
>> is still possible in a "very-high-level langage" like python3 ?
>> Why .33 could not be a Decimal directly ?
> I proposed something like this earlier, see:
> Obviously, the proposal didn't go anywhere, the reason being that
> Decimal is currently implemented in Python and is thus much too
> inefficient to be the default (efficiency/practicality beating
> correctness/purity here apparently). There are non-Python
> implementations of the decimal standard in C, but no one could locate
> one with a Python-compatible license. The closest was the IBM
> implementation whose spec the decimal PEP was based off of, but
> unfortunately it uses the ICU License which has a classic-BSD-like
> attribution clause.
Thanks to resume the situation.
I think of another question. Why it's so difficult to mix float and
For example we cannot do Decimal(float) or float * Decimal.
And i'm afraid that with python 3 it will more often a pain because
operation with two integers can sometimes return integer (and accept an
operation with decimal) and sometimes not when the operation will return
>>> a = Decimal('5.3')
>>> i = 4
>>> j = 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'float' and 'Decimal'
I mean, why if a Decimal is in the middle of an operation, float didn't
silently become a Decimal ?
William Dodé - http://flibuste.net
More information about the Python-ideas