[Python-Dev] [Python-ideas] PEP
Masklinn
masklinn at masklinn.net
Thu Mar 8 22:59:31 CET 2012
More information about the Python-Dev mailing list
Thu Mar 8 22:59:31 CET 2012
- Previous message: [Python-Dev] PEP
- Next message: [Python-Dev] FYI dict lookup now raises a RuntimeError if the dict is modified during the lookup
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2012-03-08, at 22:08 , Mark Janssen wrote: > I just noticed something in Guido's example. Something gives me a strange > feeling that using a variable as a key doesn't smell right. Presumably > Python just hashes the variable's id, or uses the id itself as the key Python calls ``hash`` on the object and uses the result. > , but > I wonder if anyone's noticed any problems with this, and whether the hash > collision problems could be solved by removing this?? No. Not that it makes sense, people could ask for object hashes on their own and end up with the same result. > Does anyone even > use this functionality -- of a *variable* (not a string) as a dict key? What you're asking does not make sense, the dict key is not the name but whatever object is bound to the name. And yes I've used non-string objects as names before: tuples, frozensets, integers, my own objects, …
- Previous message: [Python-Dev] PEP
- Next message: [Python-Dev] FYI dict lookup now raises a RuntimeError if the dict is modified during the lookup
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list