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. -- http://mail.python.org/mailman/listinfo/python-list