[Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytesand Mutable Buffer) (original) (raw)
Phillip J. Eby pje at telecommunity.com
Sat Sep 29 16:24:02 CEST 2007
- Previous message: [Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytesand Mutable Buffer)
- Next message: [Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytesand Mutable Buffer)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 08:08 PM 9/28/2007 -0700, Guido van Rossum wrote:
Likely, programmers will attempt to look up keys that they know are in the dict -- and if they use the wrong type, because of the identical hash values, they will get the TypeError as soon as they compare it to the first object at the hashed location.
I'm coming into this thread a little bit late, but if we don't want strings and bytes to be comparable, shouldn't we just make them unequal? I mean, under normal circumstances, == and != are available on all objects without causing errors, and the same TypeError would occur for things like list.remove().
This seems a lot like Oleg's question on Python-Dev the other day, about raising a TypeError from nonzero: i.e., changing a significant expectation about all "normal" objects.
While it's true that it would be good to know when you've unintentionally mixed bytes and strings, surely there could be less fatal ways to find this, like perhaps a command-line option that causes byte/string comparisons to output a warning?
- Previous message: [Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytesand Mutable Buffer)
- Next message: [Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytesand Mutable Buffer)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]