2 ms·
I feel like your reply here, and perhaps a few other comments, are confusing a few senses of the word "dynamic" (which, to be fair, is i.m.o. a reasonable confu
by jholman 10y ago
I feel like your reply here, and perhaps a few other comments, are confusing a few senses of the word "dynamic" (which, to be fair, is i.m.o. a reasonable confusion).
Python is "a dynamic language" mostly in the sense that it is "dynamically typed". (I'm sure you're aware, I'm not trying to patronize, just setting the stage.) That's one sense.
Tuples in Python are still dynamic in this sense, of course, because every damn value in Python is, for good or for ill. But there are at least two other senses in play here.
Compare C structs with, say, JS Objects. Both let you mutate the values they point to, but JS Objects let you add new property-names at will (or remove them). So one sense of "dynamic" is "resizeable".
We could also have a data type, e.g. linked lists in various "purely functional" languages, that can be resized (pushed and popped), but existing cells cannot be mutated. AIUI Clojure is full of this sort of thing.
Point #1 is that nothing in colanderman's comments argues against Python's dynamic typing.
My second and broader thought is that I agree with colanderman that it's weird that Python conflates these latter two senses of dynamism (resizeability and cell-mutability), and even more weird that it does so for one data type (the sequence) and more or less ignores it elsewhere (though e.g. frozendict does exist).
- pdonis 10y agoThere's nothing stopping you from writing Python types that separate these different senses of "dynamic". You can write a sequence type that doesn't let you change the number of cells, but does let you mutate existing cells. Or you can write one that lets you add new cells, but doesn't let you mutate cells once they are added. You can even write them as C extensions if you want the same speed and memory efficiency as the built-in types.