On Thu, 21 Apr 2022 at 06:20, Avi Gross via Python-list
<python-list@python.org> wrote:
>
> This does raise an issue, Chris, if you use the method of making a tuple 
> companion for a list at a specific time just for use as a dictionary key, 
> then later change the list, you can end up with various situations.
>

Yes. And those situations are *exactly* why you can't use a list as a key.

> Obviously the changed list can not only not access the stored item, but if 
> converted again to a tuple, may address a different item. I can see many 
> scenarios with abandoned dictionary items that are never deleted and can only 
> be reached by examining all items in the dictionary.
> So mutability is only one concern. If you actually mutate your data, ...

And if you don't mutate your data, use a tuple.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to