why sqrt is not a built-in function?

Avi Gross avigross at verizon.net
Thu Jan 14 18:51:29 EST 2021


Ethan, if it is not obvious, then should we add the following functions just
in case?

	cube_root()
		fourth_root()
			nth(root)
				two_thirds_root()
			e_th_root()
		pi_th_root()
	x_over_y_root()

And so on.

It is true that square roots are probably more commonly taken than many
others above (I have never taken the pi_th root but you never know) and you
can make a fourth root by taking the square root twice. There is nothing
wrong with creating a convenience function but it needs to stop somewhere.
The purpose of modules or packages and other add-ons is to supplement the
base language that is loaded whether you want it or not. Some have argued to
remove many current things from the base that THEY never use (or compiled
their own such version) to make it smaller and faster.

Given that, you can either import the sqrt function or make your own that
just turns around and uses one of the methods that is built-in. But if you
use all kinds of things regularly, consider importing them all at once by
having your own module with some name that imports all of them and importing
that and waiting as they all load.



-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of Ethan Furman
Sent: Thursday, January 14, 2021 2:36 PM
To: python-list at python.org
Subject: Re: why sqrt is not a built-in function?

On 1/14/21 11:06 AM, Eli the Bearded wrote:

> "There should be one-- and preferably only one --obvious way to do it."
> 
> Meanwhile, Alan Gauld pointed out:
> 
>    AG> because pow() is a builtin function and
>    AG> root = pow(x,0.5)
>    AG> is the same as
>    AG> root = math.sqrt(x)
> 
> Plus the ** operation ("root = x ** 0.5"), that's now three ways.

Yes, but which of those is obvious?

--
~Ethan~
-- 
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list