Martin v. Löwis <[EMAIL PROTECTED]> wrote: >> @overloaded >> def sqrt(value): >> raise TypeError("Cannot take square root of %s" % >> type(value).__name__) >> >> @sqrt.overload >> def sqrt_float(value : float): >> return math.sqrt(value) >> >> @sqrt.overload >> def sqrt_complex(value : complex): >> return cmath.sqrt(value) >> >> @sqrt.overload >> def sqrt_decimal(value : decimal): >> return value.sqrt() >> >> # Similar overloads can be added for the types in gmpy and numpy. > > So where would that sqrt function live? I hope you are not proposing > it becomes a builtin - I dearly wish there were fewer builtins, not > more.
"math" would be fine for all builtin types. For other types, imported from modules, such as numpy, they could add their overload to math.sqrt at import-time. Giovanni Bajo _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com