[Python-3000] Math in Python 3.0
"Martin v. Löwis"
martin at v.loewis.de
Sun May 14 08:19:49 CEST 2006
Fredrik Johansson wrote:
> For example, square roots are known as math.sqrt(x) for floats,
> cmath.sqrt(x) for complex numbers, x.sqrt() for decimals, and
> gmpy.sqrt(x)/gmpy.fsqrt(x) for gmpy's types. Oh, and SciPy has its own
> sqrt function that works on arrays (but not Decimals or gmpy's types).
Ah, I see.
>> My guess is that it isn't brought up very often because very few
>> people have the problem you are talking about.
>
> Perhaps they don't complain, but that doesn't mean that they wouldn't
> appreciate the difference :-)
Speaking for myself only: I never worried that the square root is
spelled differently for different types. I use math.sqrt perhaps
twice a year, I don't recall ever using cmath.sqrt except to demonstrate
that it doesn't raise an exception for -1, and I heard of decimals.sqrt
and gmpy.sqrt the first time in your message.
So, for me, the problem doesn't exist.
I can't think of an obvious solution, either: math.sqrt and cmath.sqrt
are intentionally different functions. They both accept -1 (an integer)
as an argument, but produce different results. So despite them having
the same name, and despite them giving equal results for some arguments,
it doesn't feel to me that these functions should get unified.
Regards,
Martin
More information about the Python-3000
mailing list