proposed language change to int/int==float (was: PEP0238 lament)
David C. Ullrich
ullrich at math.okstate.edu
Sat Jul 28 16:13:42 CEST 2001
On Fri, 27 Jul 2001 21:43:51 GMT, Guido van Rossum <guido at python.org>
>bokr at accessone.com (Bengt Richter) writes:
>> On Fri, 27 Jul 2001 08:54:13 -0400, Guido van Rossum <guido at zope.com> wrote:
>> >Assuming we'll adopt a variation of Scheme's numerical tower (which
>> >I'm currently in favor of, more or less), this won't happen. Floats
>> >and complex would always be considered inexact (and ints and rationals
>> >exact), and inexact numbers are not allowed as sequence indices, even
>> >if their exact value is an integer.
>> Why would complex have to be inexact if both its
>> real and imaginary parts were exact?
>> This looks exact, but will it be?
>> >>> (1+2j)**2
>Probably not -- I don't think it's worth to have a separate exact and
>inexact complex numbers, especially since exact numbers will probably
>be represented as rationals (with ints and long ints as a special-case
>optimization), while inexact numbers will probably all use some form
>of floating point (binary or decimal).
??? I wouldn't presume to say what's "worth it" and what isn't
(seriously, simply because none of this really matters to me,
being just an interested onlooker.) But _if_ it's worth it to
have exact and inexact real numbers I don't see why complex
numbers should be different - if you're going to revise all
this why shouldn't there be exact complexes, where real and
imag are integers or rationals, and also inexact complexes
where real and imag are floats?
(Hmm. Thinking about it, what seems worth it to me would
surely not be worth it to almost anyone else: A complex
should have alternate real-imag and modulus-arg representations,
ie representations in rectangular or polar coordinates, and
we should be able to say that _either_ is exact. Because the
calculations with "exact complexes" that interest me in
particular are with complexes where the polar coordinate
representation involves _exact_ rationals, although real
and imag are inexact. For example, if z is a complex with
|z| = 1 and arg(z) = pi/3 then z**6 should be 1, exactly.
If there were an exact complex like that that would be
Come to think of it, it's arg/pi that should be allowed
to be an exact rational for this reason, not arg.
And no, this is _not_ an actual suggestion or a request;
actually doing this in a general-purpose programming
language seems silly. But if you decide to write several
thousand versions to keep everyone happy this is a feature
that goes in my version...)
>--Guido van Rossum (home page: http://www.python.org/~guido/)
David C. Ullrich
More information about the Python-list