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 gvanrossum
Recipients gvanrossum, mark.dickinson, serhiy.storchaka, vstinner
Date 2015-01-13.18:08:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAP7+vJK46p-dUrjD-SmwN+H7WjwR+7Zd6L-YMvvKL9MFxnAOgQ@mail.gmail.com>
In-reply-to <1421170052.47.0.603843069146.issue23229@psf.upfronthosting.co.za>
Content
I don't understand why w ends up having -0 as the real part. For floats, at
least, we've done a lot of work to make eval(repr()) roundtrip correctly in
all cases. Is the issue with complex superficial (we should fix eval or
repr) or deep (if we fixed it something else would be broken)?

On Tue, Jan 13, 2015 at 9:27 AM, Mark Dickinson <report@bugs.python.org>
wrote:

>
> Mark Dickinson added the comment:
>
> > Having them in the cmath module provides a place
> to document them which will then be searchable.
>
> Okay, makes sense.
>
> One of the reasons I'm a bit unhappy with the idea of adding infj and nanj
> is that it seems like an encouragement to expect "eval(repr(z))" to work
> (i.e., recover the original value of z), and because Python doesn't have
> strict imaginary numbers (i.e., numbers with no real part at all), that
> fails:
>
> >>> from math import inf, nan
> >>> infj = complex(0.0, inf)
> >>> nanj = complex(0.0, nan)
> >>> z = complex(0.0, -inf)
> >>> w = eval(repr(z))
> >>> z
> -infj
> >>> w  # real part has the "wrong" sign
> (-0-infj)
>
> But that's a pretty hollow objection, because this really has nothing to
> do with inf and nan; it's a problem with finite values, too:
>
> >>> z = complex(0.0, -3.4)
> >>> w = eval(repr(z))
> >>> z
> -3.4j
> >>> w
> (-0-3.4j)
>
> So I'll add infj and nanj if the consensus is that they're useful.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue23229>
> _______________________________________
>
History
Date User Action Args
2015-01-13 18:08:37gvanrossumsetrecipients: + gvanrossum, mark.dickinson, vstinner, serhiy.storchaka
2015-01-13 18:08:37gvanrossumlinkissue23229 messages
2015-01-13 18:08:37gvanrossumcreate