The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)
BartC
bc at freeuk.com
Sat Mar 12 18:57:31 EST 2016
On 12/03/2016 22:10, Marko Rauhamaa wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> I completely agree with you that the keyword should mean "write-once"
>> or "never rebind".
>
> That would be possible. I'm afraid that would result in people
> sprinkling these "constant" keywords everywhere to make the program
> supposedly run faster. -- Something like that has happened with the
> "final" keyword in some Java houses.
I use 'const' everywhere in other languages, most often in the form of
sophisticated sets of enums. A single project might have 1000 or even
2000. (Example that defines a set of byte-codes:
http://pastebin.com/q1UwjKmK)
How does Python manage without them? Is it really necessary to declare
hundreds of individual variables and assign a value to each? (And risk
someone assigning a new value to them.)
That they might lead to more efficient code is secondary, but definitely
a bonus (essential though when used in a switch statement).
--
Bartc
More information about the Python-list
mailing list