> > Moreover, if you put a mutable object into a dict and then change one of > its fields and its hash depended on that field value, then it will be > "lost" in the sense that if you check for that *same object* being in the > dict, it will appear not to be, since it no longer ends up in the same hash > bucket.
I had that bite me a few weeks ago, when all the keys in the dictionary pointed to the same array, i.e. the last key inserted. Wouldn't it be sensible to copy the mutable keys by default, or at least have some warning in the documentation? I've recently learned that Python forbids mutable key types for that exact same reason.
