"Jim Jewett" email@example.com wrote:
Tim Peters wrote:
complex_new() ends with:
cr.real -= ci.imag; cr.imag += ci.real;
and I have no idea what that thinks it's doing. Surely this isn't intended?!
I think it is. python.org/sf/1642844 adds comments to make it less unclear.
If "real" and "imag" are themselves complex numbers, then normalizing the result will move the imaginary portion of the "real" vector into the imaginary part and vice versa.
Not really. What it does is to make complex(a,b) exactly equivalent to a+1j*b. For example:
a = 1+2j b = 3+4j complex(a)
Note that changing this (to discard the imaginary parts) would break passing complex numbers to their own constructor.
Eh? Now, I am baffled. There are several ways of changing it, all of which would turn one bizarre behaviour into another - or would raise an exception. Personally, I would do the following:
complex(a) would permit a to be complex.
complex(a,b) would raise an exception if either a or b were complex.
But chacun a son gout (accents omitted).
Regards, Nick Maclaren, University of Cambridge Computing Service, New Museums Site, Pembroke Street, Cambridge CB2 3QH, England. Email: firstname.lastname@example.org Tel.: +44 1223 334761 Fax: +44 1223 334679