[Python-Dev] Backport new float repr to Python 2.7? (original) (raw)

Guido van Rossum guido at python.org
Mon Oct 12 20:48:54 CEST 2009


On Mon, Oct 12, 2009 at 11:41 AM, Mark Dickinson <dickinsm at gmail.com> wrote:

[Guido]

PS. str(x) still seems to be using %.12g -- shouldn't it be made equal to repr() in 3.1 or 3.2? That I would call a bug, an oversight. But str still has some value in py3k:  it protects users from accumulated rounded errors produced by arithmetic operations: [...]

I know, but this is much more questionable now. Making str() and repr() different was an intentional choice when repr() would often show ugly values even if the input was pretty; but now str() just hides real differences (1.3 != 1.2 + 1.1), and the difference between str() and repr() is pretty subtle. (Show of hands for those who didn't even know there was a difference? :-). I think if we had to start from scratch with the 3.1 float repr() I would have made float's str() equal to its repr(). But this is at most a +1 feeling.

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list