[Python-ideas] An identity dict

Greg Ewing greg.ewing at canterbury.ac.nz
Mon May 31 02:30:25 CEST 2010


Benjamin Peterson wrote:
> Lie Ryan <lie.1296 at ...> writes:
> 
>>what's wrong with dict[id(key)] = foo?
> 
> For one, you can't get the value of the key out of the dict.

Another thing is that it doesn't keep the key object
alive, so if the app doesn't do anything else to ensure
this, it's possible for the key to disappear and be
replaced by another object having the same id.

-- 
Greg



More information about the Python-ideas mailing list