No complex rationals in Python 3.0

Christian Heimes lists at cheimes.de
Mon Nov 24 14:31:39 EST 2008


Rock wrote:
> 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.

Nobody has submitted a PEP and patch to implement the feature in time. 
There is still Python 3.1, you know? If you like to contribute the 
feature then please start a discussion on the Python Ideas mailing list 
(not the developer lists!).

> 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.

The code depends on the CLN library which isn't suited for the Python 
core. It's written in C++ and it's licensed under GPL. Neither GPL nor 
LGPL software can't be integrated into the core. We also require all 
code to be compatible with C89.

Christian




More information about the Python-list mailing list