A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/033083.html below:

[Python-Dev] Re: Pre-PEP: Mutable keys in dictionaries

[Python-Dev] Re: Pre-PEP: Mutable keys in dictionaries [Python-Dev] Re: Pre-PEP: Mutable keys in dictionariesEric mailing-lists@digitaleric.net
Thu, 06 Feb 2003 12:09:55 -0500
Just van Rossum wrote:

[snip]
> 
> The __temporary_immutable__ part of the protocol is needed to avoid
> unneccesary copying in those cases where the key isn't actually inserted
> into the dict, but is only used for membership testing. It would return
> a wrapper around the mutable object, defining __eq__ and __hash__. (This
> idea is stolen from the sets.py module.) If an implementer doesn't care
> about this efficiency, __temporary_immutable__ can be an alias to
> __immutable_copy__.

Can __temporary_immutable__ work on a multi-threaded system?  What is to 
prevent the (known to be mutable) key from changing underneath you during 
the lookup?  Perhaps I am misunderstanding, but it seems to me that you 
must either copy the mutable key or be able to block all writers to the key 
during the lookup.

Other than that, I very much like the idea of using mutable keys :)

-Eric




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4