[Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytes and Mutable Buffer)

Christian Heimes lists at cheimes.de
Sat Sep 29 17:28:16 CEST 2007


Jim Jewett wrote:
> On 9/27/07, Guido van Rossum <guido at python.org> wrote:
>> On 9/27/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> 
>>> Should a TypeError be raised as soon as you try to put a bytes and a
>>> string in the same dict, even if they don't happen to hash equal?
> 
>> Good idea, if you can figure out a way to implement this efficiently.

What do you think about using the class hierarchy for the job? Instead
of raising a TypeError a comparison between a string and a byte raises
StringBytesError that subclasses from TypeError. The dict methods like
lookdict() then reraise the StringBytesError explicitly.

I'm know very little about the dict implementation and my idea could be
totally wrong ... The idea just came to me and perhaps it helps to find
the solution.

Christian



More information about the Python-3000 mailing list