Mutable objects as mapping keys

Clint Jeffery (cjeffery@cs.arizona.edu)
Fri, 26 Mar 1993 06:20:37 MST

(1) do you think that disallowing lists as keys is a big drawback?

Its not a practical drawback, it is merely a drawback in "elegance".
It seems cleaner to do this than to do the deep copy thing though.

(2) would you accept the performance penalty of always deep copying
lists used as keys? (2a) when using lists (2b) when not using lists!

How deep? Does Python allow cycles in such structures?

(3) do you happen to have another implementation idea?

Icon allows structure keys, and such keys can change -- lists have an
associated serial number that is used for hashing since neither the
contents nor the pointer to the list are safe to hash on. It is fast,
cheap, and consistent with the mutable nature of (Icon) lists...but
maybe Python lists are qualitatively different than Icon lists.