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 docs@python, josh.r, mark.dickinson, rhettinger, rushilu, serhiy.storchaka, steven.daprano, tim.peters
Date 2020-04-19.09:55:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587290139.54.0.221472239337.issue40269@roundup.psfhosted.org>
In-reply-to
Content
> I tried to make repr of floats producing a string which rounds up with eval()

We've looked at this before. There just isn't any sane and easy way to do this, except for changing the repr to be "complex(real, imag)", which is the solution that I favour.

And this seems like a non-starter to me:

    >>> complex(0.0, -0.0)
    -(-0.0-0j)

This is a case where the cure is worse than the disease.

We should also not change the repr lightly: the last time it was changed, it caused disruption at least for Cython, and probably for NumPy too. As a corollary, if we _do_ change it, we should make sure we get it right so that we're changing it to something we're not going to want to change again in 5 years' time. And I suspect that if we don't solve the underlying roundtrip problem, then this is going to come up again.

I'm +1 on changing the repr to "complex(..., ...)", +0 on modifying it to always include both real and imaginary parts _and_ format those parts as though they're floats; -1 on other changes.
History
Date User Action Args
2020-04-19 09:55:39mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, steven.daprano, docs@python, serhiy.storchaka, josh.r, rushilu
2020-04-19 09:55:39mark.dickinsonsetmessageid: <1587290139.54.0.221472239337.issue40269@roundup.psfhosted.org>
2020-04-19 09:55:39mark.dickinsonlinkissue40269 messages
2020-04-19 09:55:38mark.dickinsoncreate