[Python-ideas] Python Numbers as Human Concept Decimal System
Chris Angelico
rosuav at gmail.com
Fri Mar 7 05:29:15 CET 2014
On Fri, Mar 7, 2014 at 3:17 PM, Mark H. Harris <harrismh777 at gmail.com> wrote:
> On Thursday, March 6, 2014 9:12:32 PM UTC-6, Ben Finney wrote:
>
>>
>> But beware that even there, complaints about how Python behaves aren't
>> going to be well received if you show a wilful ignorance of that
>> behaviour. Mere ignorance is fine, of course: we all start out ignorant
>> of any given topic. But wilful ignorance isn't a good foundation for
>> expecting change.
>
> Ben, excuse me, but you are out of line here. I have not shown
> will full ignorance in any of this discussion (None).
Hey hey, I'd be careful of calling someone out like that... might want
to be a little humble and respectful here :)
The main problem here is that you and the Python interpreter have
different expectations about a string of digits in the source code.
You expect them to be represented exactly; the language specifies that
they be represented with the float type. Changing how the language
interprets something as fundamental as "number with decimal point in
it", even if unassailably correct, is a backward-incompatible change.
(The full unification of the int and long types wasn't effected until
Python 3, even though that change is unlikely to break much code.)
If someone wants to push for it, write the PEP, go through all the
details, then it'd be possible to have this for Python 3.5:
>>> 0.1d == Decimal("0.1")
True
But you're not going to have that effect for untagged numbers without
a long deprecation period; probably we're talking Python 4000, which
may not ever even exist. It'd be possible to have a __future__
directive that switches around the two types, so decimal is the
default and binary floats have to be tagged, but that could cause so
much confusion that it'd itself be the subject of massive controversy.
(Although there would be precedent for it. "from __future__ import
unicode_literals" didn't destroy Py2 code readability.)
ChrisA
More information about the Python-ideas
mailing list