[Tutor] TypeError: dict objects are unhashable

Lie Ryan lie.1296 at gmail.com
Sun Mar 15 12:40:10 CET 2009

Emile van Sebille wrote:
> Mark Tolonen wrote:
>>>>> [dict(n) for n in set(tuple(n.items()) for n in l1)]
> Anyone know if the ordered items for two different dicts where dicta == 
> dictb is guaranteed the same?  I know the ordering is unspecified but 
> you can depend on the sequence of keys matching data and I think it'll 
> also match items.
> but for all DA's and DB's below, is that true?

Considering how dictionary is implemented, I don't think so. The 
dictionary is internally implemented as a hash table, and two dictionary 
with identical items may have different sized hash table, the algorithm 
guarantees efficient usage of memory (it resizes when it's too small or 
too big). On a resize, the hashes are recalculated and the ordering 

More information about the Tutor mailing list