Message86354
Updated patch:
4. also simplify complex printing: no special handling for nans or
infinities. This means that e.g. complex(1, inf) prints as
"1 + infj" instead of "1+inf*j".
This might look ugly, but I think it's better than what was there
before. Complex reprs are now more uniform and easier to parse
by external code. And the expression "1 + inf*j" doesn't give
the right thing anyway, even if you replace j by 1j and inf by
float(inf):
>>> inf = float('inf')
>>> 1 + inf*j
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'j' is not defined
>>> 1 + inf*1j # expect (1+infj), but get nan in real part:
(nan+infj)
Furthermore, with these simplifications to printing and
parsing, roundtripping now works: the output of repr(z)
is valid input to
5. Print real part if it's negative zero: z =complex(-0.0, 0.0)
now prints as -0 + 0j instead of just 0j, so again roundtripping
works: complex(repr(z)) recovers z exactly.
6. Change PyOS_ascii_strtod to always output a sign when requested,
even for nans. As far as I can tell, the complex formatting is
the only place that's affected by this. Eric? |
|
Date |
User |
Action |
Args |
2009-04-23 08:35:55 | mark.dickinson | set | recipients:
+ mark.dickinson, eric.smith |
2009-04-23 08:35:55 | mark.dickinson | set | messageid: <1240475755.09.0.337248337965.issue5816@psf.upfronthosting.co.za> |
2009-04-23 08:35:53 | mark.dickinson | link | issue5816 messages |
2009-04-23 08:35:52 | mark.dickinson | create | |
|