Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Bartc Newsgroups: comp.lang.python Subject: Re: Question about math.pi is mutable Date: Sat, 7 Nov 2015 13:00:37 +0000 Organization: A noiseless patient Spider Lines: 52 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 7 Nov 2015 12:58:28 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="cf45b3961a050227b1103bebc3cbc15a"; logging-data="12139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mG1nElKbrR3jhmDKqWDmj" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: Cancel-Lock: sha1:9O7DqG5YpytRwcnWez3z4P2v6ic= Xref: csiph.com comp.lang.python:98392 On 07/11/2015 12:15, Ben Finney wrote: > Bartc writes: > >> To my mind, Python allows far too much freedom in being able to change >> anything at any time. > > You're welcome to that opinion. I don't see you present a reason why it > should affect anyone else's opinion of Python, though. Not just my option. From this 2010 paper for example ('High performance implementation of Python for CLI ...' by Antonio Cuni): "As a language, Python is very hard to implement efficiently: the presence of highly dynamic constructs makes static analysis of programs extremely difficult, thus preventing ahead of time (AOT) compilers to generate efficient target code." >> Yet Python has to assume 100% of the time that it could have been >> changed. Think of the opportunities for optimising if the probability >> was 0%. > > Such a pity that Python is missing all those opportunities for > widespread adoption, by not hewing closer to your preferences. Plenty of other people working on faster Pythons appear to have trouble with its being so dynamic. (Earlier this year, I was upgrading my own language to be much more Python-like in its internal workings. But I gave it up because I was losing so many nice features that also made it easy to implement efficiently. As one example of many, named constants (the 'const' feature earlier in the thread), were used for 'switch' statements. Without 'const', then I couldn't have a fast 'switch'.) I suppose my coding style is just different from people who write Python. When I define a function f(), then it's always going to be function f and is never going to change. A call to such a function can therefore be streamlined. If I ever need it to be dynamic, then I use a function pointer: g=f f is still the static function, g is a now a reference to it, and is a little slower to call. But the /vast majority/ of function calls are going to be static. -- Bartc