In article <[EMAIL PROTECTED]>, "Dan Bishop" <[EMAIL PROTECTED]> wrote:
> Roy Smith wrote: > > Torsten Mohr <[EMAIL PROTECTED]> wrote: > > > reading the documentation (and also from a hint from this NG) > > > i know now that there are some types that are not mutable. > > > > > > But why is it this way? > > > > > > From an overhead point of view i think it is not optimal, > > > for example for a large string it could be much faster to > > > have it changed in place, not generating a new one for > > > every step in a change. > > > > There has been a huge amount written about immutable types recently. > A > > search of the Google news archives should turn up tons of articles. > > > > But, in a nutshell, the biggest reason for immutable types (tuples > and > > strings) is that this lets they be dictionary keys. If you want to > know > > why dictionary keys have to be immutable, > > More precisely, dictionary keys can't be mutable in any way that > affects the result of the hash function or the == or != operators. Yes, this is true. In fact, I spent a fair amount of time in the referenced thread arguing exactly that point. I was hoping people would take my hint, read the thread, and find that out :-) -- http://mail.python.org/mailman/listinfo/python-list