[Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytes and Mutable Buffer) (original) (raw)
Guido van Rossum guido at python.org
Fri Sep 28 19:36:57 CEST 2007
- Previous message: [Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytes and Mutable Buffer)
- Next message: [Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytes and Mutable Buffer)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Well, maybe this is a good enough argument to give up. If the best we can say is that having a bytes and a str as keys may cause a TypeError on lookups, I'm not sure it is worth it to try to raise the probability that it'll actually be raised...
--Guido
On 9/28/07, Jim Jewett <jimjjewett at gmail.com> 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. In news that may surprise no one, there were corner cases... (1) Does it have to raise the TypeError eagerly in all cases, or is it OK to do so only when its easy? For example, would it be OK to stop verifying once some keys have been deleted? (2) Is the restriction "sticky" for a dict, or based on current contents? Current contents makes sense, but ... If code clears an existing dict rather than creating a new one, then that specific dict is probably a communication channel, and the API should specify whether it takes bytes or characters. -jJ
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytes and Mutable Buffer)
- Next message: [Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytes and Mutable Buffer)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]