Tuples -- who needs 'em
jon at dgs.monash.edu.au
Wed Apr 5 21:37:07 EDT 2000
I nearly fell out of my tree when Alexander, Bob declared:
>I am wondering where the serious concern about mutable lists comes from, as
>it is a pattern in the responses I've gotten on this topic. For me, the
>immutable list is a relatively new concept, since I can't think of many
>other languages that have it. I'm a programming-language-design kind of
>person, and I never really saw mutable lists as a problem that needed
How about C? Surely 'const' is an attempt to mark arrays as immutable.
Apparently, the ANSI C committee saw mutable arrays as a problem that
>I've used many Python-type languages that have mutable lists but
>not immutable ones, and if I don't want the elements to change they don't
>change -- I simply avoid the x[i] = y construct :-)
Avoiding the x[i] = y construct is much harder in non-trivial programs,
where assumptions about mutability need to be specified as part of the call
interface. Hence the proliferation of const in the C string library.
>And I still haven't
>heard from anyone about why there isn't similar concern about immutable
I could express some concern, but dictionaries are used much less than
sequences, and of all the places in my code where I make possibly needless
copies of a dictionary, it is usually to modify the dictionary with a clear
conscience, not something that immutability would solve.
More information about the Python-list