
I appreciate the inclusion of the fractions module in Python 2.6 and therefore in Python 3.0. But I feel there's something missing: no possibility for complex rationals (or arbitrary precision) integers. I was just checking the complex number support in Python, compared, for instance, to Common Lisp and Scheme, and I realized that there was this subtle omission. The inclusion of rationals and arbitrary integers is cool, but the numeric tower (say, compared to Scheme) is not complete. I don't think there would be a performance hit if complex rationals were provided. Ordinary operations on complex floats, in theory, should not be affected and handled separately. But it would be nice to be able to do: (3/4 + 1/2j) * (1/4 - j) = 11/16 - 5/8j with no loss of precision. Python is heavily used in math and science all over the world. We've even got a recent symbolic math project (sympy) that looks very promising, so I guess this could be an important issue. Note: there exists a library that implements what I'm talking about: http://calcrpnpy.sourceforge.net/clnum.html but still I personally would have liked to see this stuff included natively in the new Python 3.0.

It's way too late in the 3.0 release cycle, but feel free to submit a patch for inclusion into 2.7 and 3.1. On Mon, Nov 24, 2008 at 12:01 PM, Rocco Orlando Rossi <rocco.rossi@gmail.com> wrote:
-- --Guido van Rossum (home page: http://www.python.org/~guido/)

On Mon, Nov 24, 2008 at 8:01 PM, Rocco Orlando Rossi <rocco.rossi@gmail.com> wrote:
This seems like a specialist need to me---one that belongs in a Python extension package or library, but not in core Python. Another thought: the field Q(i) is just one of an infinite number of quadratic extensions of the field of rationals. Why implement that one and not the others? Put another way, the field of complex numbers is a fairly natural object, but the choice to represent it as reals adjoin sqrt(-1) is quite arbitrary---one could just as easily adjoin sqrt(-2), or sqrt(-3), or (-1+sqrt(-3))/2 instead. Have you investigated sage? (www.sagemath.org) Mark

On Mon, Nov 24, 2008 at 8:58 PM, Arnaud Delobelle <arnodel@googlemail.com> wrote:
If we want Q(i), then surely we also want Z[i]. Gaussian integers have plenty of uses.
Sure, but what are the uses of Z[i] that don't also apply to other rings of integers of quadratic fields? I guess I can see uses in teaching: if you're playing around with complex numbers for the first time then it's possible that all your calculations actually lie in Q[i]. Mark

It's way too late in the 3.0 release cycle, but feel free to submit a patch for inclusion into 2.7 and 3.1. On Mon, Nov 24, 2008 at 12:01 PM, Rocco Orlando Rossi <rocco.rossi@gmail.com> wrote:
-- --Guido van Rossum (home page: http://www.python.org/~guido/)

On Mon, Nov 24, 2008 at 8:01 PM, Rocco Orlando Rossi <rocco.rossi@gmail.com> wrote:
This seems like a specialist need to me---one that belongs in a Python extension package or library, but not in core Python. Another thought: the field Q(i) is just one of an infinite number of quadratic extensions of the field of rationals. Why implement that one and not the others? Put another way, the field of complex numbers is a fairly natural object, but the choice to represent it as reals adjoin sqrt(-1) is quite arbitrary---one could just as easily adjoin sqrt(-2), or sqrt(-3), or (-1+sqrt(-3))/2 instead. Have you investigated sage? (www.sagemath.org) Mark

On Mon, Nov 24, 2008 at 8:58 PM, Arnaud Delobelle <arnodel@googlemail.com> wrote:
If we want Q(i), then surely we also want Z[i]. Gaussian integers have plenty of uses.
Sure, but what are the uses of Z[i] that don't also apply to other rings of integers of quadratic fields? I guess I can see uses in teaching: if you're playing around with complex numbers for the first time then it's possible that all your calculations actually lie in Q[i]. Mark
participants (5)
-
Arnaud Delobelle
-
Guido van Rossum
-
Mark Dickinson
-
Rocco Orlando Rossi
-
Terry Reedy