This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients Ultrasick, Zeev.Rotshtein, mark.dickinson
Date 2012-05-03.17:34:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1336066459.1.0.765115327183.issue5118@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2012-05-03 17:34:19mark.dickinsonsetrecipients: + mark.dickinson, Ultrasick, Zeev.Rotshtein
2012-05-03 17:34:19mark.dickinsonsetmessageid: <1336066459.1.0.765115327183.issue5118@psf.upfronthosting.co.za>
2012-05-03 17:34:18mark.dickinsonlinkissue5118 messages
2012-05-03 17:34:18mark.dickinsoncreate