When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?
Chris Cioffi
evenprimes at gmail.com
Mon Apr 23 11:30:51 EDT 2007
On 23 Apr 2007 17:19:15 +0200, Neil Cerutti <horpner at yahoo.com> wrote:
> So the question becomes: Why do Python dictionaries require keys
> to be of an immutable type?
Dictionary keys are hashed values. If you change the key, you change
the hash and lose the pointer to the referenced object.
Or: Because. ;-)
Chris
--
"A little government and a little luck are necessary in life, but only
a fool trusts either of them." -- P. J. O'Rourke
More information about the Python-list
mailing list