Mark Dickinson <dicki...@gmail.com> added the comment:

> That's because Python uses floating point registers of the x86-CPU-
> architecture to store point values. This method is inaccurate and causes
> such problems.

Yes, exactly;  this is the root cause.

And as you suggest, Python *could* use a different numeric storage format that 
doesn't suffer from loss of information when initializing a number from a 
decimal string.  There's an obvious candidate for that storage format, and 
that's the decimal.Decimal type.

There are some issues, though:

(1) decimal.Decimal operations are implemented in software (in pure Python for 
versions <= 3.2, and now in C in Python 3.3) and so are orders of magnitude 
slower than hardware-supported floats.  That's one of the reasons that almost 
every mainstream programming language uses the binary-represented hardware 
floats as the main way of representing non-integral numbers.  The need for 
those fast floats isn't going to go away in a hurry.  The obvious solution here 
would be to for Python to support both binary floats and decimal floats, and 
perhaps to make numeric literals default to being decimal.Decimal instances.

(2) Getting to the point where the Decimal type could be used for numeric 
literals will be a *long* road, full of backwards compatibility concerns, PEPs, 
and long and probably contentious python-dev discussions.  Python's just taken 
the first step along that road by reimplementing the decimal module in C for 
Python 3.3;  this improves the speed significantly (though floats are still 
significantly more efficient in both time and space, and likely will be for a 
long time), and also makes it easier to start using decimal more widely from 
within the core of Python.

Reaching that point of having the Decimal type more fully integrated into 
Python is something that I know a good few of the Python developers are 
interested in (including me).  But it's not going to be an easy or quick change.

> @Mark: And I am also one of thouse who lost a lot of interrest in helping out 
> in the futher development of
> Python. It was because your haughtiness.

I see how my earlier messages came across badly.  I apologise for that, and I 
hope you won't let the poorly chosen words of just one Python developer out of 
many put you off future involvement in Python.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5118>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to