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 steven.daprano
Recipients Marco Sulla, eric.smith, steven.daprano, zach.ware
Date 2020-02-29.18:30:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20200229182958.GB4624@ando.pearwood.info>
In-reply-to <1582998609.09.0.790297711355.issue39788@roundup.psfhosted.org>
Content
> Integers are implicitly converted to floats in operations with floats. 
> How can this change break old code?

# Status quo
print(1e60 + 1)
=> prints 1e+60

# In the future:
=> prints 1000000000000000000000000000000000000000000000000000000000001

# Status quo
1e300*1e300
=> returns inf (a float)

# In the future
=> returns 1000000...000000 (600 zeroes, an int)

# Status quo:
1e300**10000
=> instantly raises overflow error

# In the future
=> locks up the machine until you run out of memory

etc.

> > if you are worried about the performance
> 
> No, I'm worried about the expectations of coders.

Oh that's good then, because exponentional notation like 1e10 has been 
well known to return a float in Python for over a quarter of a century, 
and in dozens or hundreds of other languages too. It is, as far as I can 
tell, universally true that coders can distinguish floats from ints (in 
languages that distinguish them) using a simple test:

- if it contains a ".", "e" or "E", it's a float
- otherwise its an int

I don't know of any languages where numbers containing a dot or an "E" 
are ints. Do you?

> If I wanted a float, I'd wrote 1.0E2 

But by your own feature request, this would return an int and your 
"feature" would bite you:

    if the "base number" has a number of decimal places <= the
    exponent, the result should be an integer.

You would need to write 1.000E2 for it to work. Luckily for you, we're 
rejecting this idea, before it can fool you into writing buggy code :-)
History
Date User Action Args
2020-02-29 18:30:24steven.dapranosetrecipients: + steven.daprano, eric.smith, zach.ware, Marco Sulla
2020-02-29 18:30:24steven.dapranolinkissue39788 messages
2020-02-29 18:30:23steven.dapranocreate