[Python-bugs-list] Inverse hyperbolic functions in cmath module (PR#231)
Sat, 11 Mar 2000 13:46:05 -0500 (EST)
> C doesn't define any functions on complex numbers -- cmathmodule.c
> implements these all on its own.
> As an aside, if anyone ever wants to trim the number of builtin C
> modules, I found that it was much easier to write cmath.py than to
> write cmath.java (for JPython). The same cmath.py should work fine
> in CPython.
Yes, I don't see anything in cmathmodule.c that *needs* to be coded in C; &
coding would be much clearer in Python, using infix notation for the basic
complex binary ops. Two possible reasons for leaving it in C:
1. Lower internal call overheads (i.e., speed).
2. Improving quality -- complex libraries are very difficult to get right
in all cases if they're made IEEE-754 aware, and doing so requires
with the processor-level 754 control & status features. But there's no
portable way to do that now, and won't be until the next iteration of C.
> I can dig it up, but I can't swear that I used the most numerically stable
I can: you didn't <wink>. Doesn't matter, though! cmathmodule.c is naive
too, and achieving good accuracy across the whole domain is a major
undertaking. That gives the best reason to write it in Python:
3. There's a long way to go to make this "industrial strength", so the
current cmath is really just a prototype. Everyone knows prototyping
is much easier in Python. QED <wink>.
> It did give the same numbers as CPython's cmath on a test set.
So ship it <wink>.