On 5/13/06, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > It's fine for > > calculating with nothing but floats, or nothing but ints, but writing > > code that works for ints, floats, complexes *and* Decimals - let alone > > for custom types such as mpfs or numeric arrays - is nearly > > impossible. Duck typing doesn't work because these types all have > > different interfaces, despite being functionally (or conceptually) > > equivalent for many purposes. > > Why do you say that? To me, it seems that these types have all > *precisely* the same operations: +, -, *, /.
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). > 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 :-) Fredrik Johansson _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
