Unicode and dictionaries

Martin v. Loewis martin at v.loewis.de
Sun Jan 17 20:34:05 CET 2010


>>> This ought to be a bug; objects that compare equal and are hashable
>>> must have the same hash code.
>> It's not a bug. Changing the default encoding is not really supported,
>> let alone changing it to anything but latin-1, precisely for the reasons
>> you discuss.
>>
>> If you do change the default encoding, Python *will* break. This has
>> been discussed many times, but some people still think they know better.
> 
> 
> That's specific to CPython though, isn't it? Other implementations may, 
> or may not, cope with it better?

No, that's fairly inherent to the problem. Only if that other
implementation doesn't use hashing for dictionaries, the problems
might go away. However, this is fairly unlikely - in particular,
since the language spec nearly mandates that dictionaries are hash-based
(rather than relying on comparability).

Regards,
Martin



More information about the Python-list mailing list