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

2007-09-29 Thread Phillip J. Eby
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

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

2007-09-29 Thread Guido van Rossum
On 9/29/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > 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

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

2007-09-29 Thread Phillip J. Eby
At 07:33 AM 9/29/2007 -0700, Guido van Rossum wrote: >Until just before 3.0a1, they were unequal. We decided to raise >TypeError because we noticed many bugs in code that was doing things >like > > data = f.read(4096) > if data == "": break Thought experiment: what if read() always returned st

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

2007-09-29 Thread Michael Urman
On 9/29/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 9/29/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > 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 circumstan

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

2007-09-29 Thread Christian Heimes
Jim Jewett wrote: > On 9/27/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> On 9/27/07, Jim Jewett <[EMAIL PROTECTED]> 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

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

2007-09-29 Thread Phillip J. Eby
At 10:26 AM 9/29/2007 -0500, Michael Urman wrote: >[Sending direct because this is just a thanks and some idea fodder, >but feel free to return this to the list] > >On 9/29/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > can both be constants, a simple list.index() test could now raise a > > Type

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

2007-09-29 Thread Jeffrey Yasskin
On 9/29/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > At 07:33 AM 9/29/2007 -0700, Guido van Rossum wrote: > >Until just before 3.0a1, they were unequal. We decided to raise > >TypeError because we noticed many bugs in code that was doing things > >like > > > > data = f.read(4096) > > if data

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

2007-09-29 Thread Gregory P. Smith
On 9/29/07, Jeffrey Yasskin <[EMAIL PROTECTED]> wrote: > > On 9/29/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > At 07:33 AM 9/29/2007 -0700, Guido van Rossum wrote: > > >Until just before 3.0a1, they were unequal. We decided to raise > > >TypeError because we noticed many bugs in code that was

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

2007-09-29 Thread Terry Reedy
"Guido van Rossum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Until just before 3.0a1, they were unequal. I think it valuable that in the language as delivered, 'o==p' (as well as 'bool(o)' )always return True or False. Both make reasoning about code easier since one does n

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

2007-09-29 Thread Phillip J. Eby
At 12:04 PM 9/29/2007 -0700, Gregory P. Smith wrote: >On 9/29/07, Jeffrey Yasskin ><[EMAIL PROTECTED]> wrote: >On 9/29/07, Phillip J. Eby ><[EMAIL PROTECTED]> wrote: > > At 07:33 AM 9/29/2007 -0700, Guido van Rossum wrote: > > >Until just befo