[Python-ideas] An identity dict
Raymond Hettinger
raymond.hettinger at gmail.com
Mon May 31 06:11:54 CEST 2010
On May 30, 2010, at 7:56 AM, Lie Ryan wrote:
> On 05/31/10 00:23, Benjamin Peterson wrote:
>> Lie Ryan <lie.1296 at ...> writes:
>>> what's wrong with dict[id(key)] = foo?
. . .
>>
>
> it may be useful, but if you can emulate it relatively easily with
> regular dict, why bother with a new type?
I agree that this would be a waste.
Also, I haven't seen much of a discussion of use cases.
It's been possible to make identity dictionaries for a very
long time, yet I can't remember the last time I saw one used.
The Python language makes very few guarantees about
object identity so it is mainly only usable in a few circumstances
where an object is continually referenced by something outside
the identity dict.
I would like to see an identity dict posted an ASPN recipe
to see if anyone actually uses it.
Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100530/464b4412/attachment.html>
More information about the Python-ideas
mailing list