[Python-Dev] What should a good type checker do? (was: Please reject or postpone PEP 526) (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Sep 2 21🔞34 EDT 2016


Chris Angelico wrote:

Forcing people to write 1.0 just to be compatible with 1.5 will cause a lot of annoyance.

Indeed, this would be unacceptable IMO.

The checker could have a type 'smallint' that it considers promotable to float. But that wouldn't avoid the problem entirely, because e.g. adding two smallints doesn't necessarily give a smallint.

Seems to me the practical thing is just to always allow ints to be promoted to floats. It's possible for runtime errors to result, but this is Python, so we're used to those.

-- Greg



More information about the Python-Dev mailing list