On 15/01/2021 06.44, Denys Contant wrote: > I don't understand why sqrt is not a built-in function. > Why do we have to first import the function from the math module? > I use it ALL THE TIME! > > That felt good. Thank you.
Are you 'venting', or do you have a specific frustration-induced question? Much of my training work centers on HTML5. An issue which you will have experienced as a user (if not an HTML5 coder), is how long it takes for certain pages to load or to respond to a 'click'. We talk of the "weight" of the page. Sadly, in a bid to "capture eye-balls" and/or to prove how much smarter 'I' am (than any other web-author/JavaScript-er), there are (far too) many reasons why web-pages are adorned and accompanied by myriad scripts (and likely, whole libraries/frameworks), and thus become slow (or 'heavy'). What does this have to do with Python? As an "interpreted language" Python will (tend to) execute slowly when compared with a "compiled language". (ignoring 'shades and grades', and purity of definition) Another form of delay/slow-ness, is how long it takes a program(me) to start (in the eyes of the user). Another form of 'weight', and component of start-up time is how much storage is required to hold the code (excluding any data). An advantage of Python is that it has a small 'core'. Mark Summerfield (author) refers to it as "Python's beautiful heart". The minimised core (or should that be "optimised"?) is fast to load, and occupies minimal resource. As a consequence, you and I may well grumble that we have to import the math library - every time we code some non-trivial calculation. However, in doing-so we (should) compute a conscious cost-benefit analysis: knowing that to include the library will incur a resource-cost, but that its facilities will improve the accuracy and/or efficiency (eg speed) of our work. OK, so sign me up! Contrarily, people who don't 'work with numbers', eg other threads 'here' discussing character manipulation; don't experience any longer waiting-time or 'suffer' extra resource-cost, due to loading the math library, from which they/their code will receive no benefit at all! Thus, one of the philosophies of Python I keenly appreciate (that makes me "[feel] good", to borrow your words), is that not only are "batteries included", but I don't have to carry-around any 'spare batteries' that I don't actually need right now! (even more applicable when using MicroPython, etc) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list