[Python-3000] Immutable bytes type and dbm modules

Chris Monson shiblon at gmail.com
Tue Aug 7 16:59:31 CEST 2007


On 8/6/07, Guido van Rossum <guido at python.org> wrote:
>
> On 8/6/07, Chris Monson <shiblon at gmail.com> wrote:
> > On 8/6/07, Guido van Rossum <guido at python.org> wrote:
> > > On 8/6/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> > > > b) should bytes literals be regular or frozen bytes?
> > >
> > > Regular -- set literals produce mutable sets, too.
> >
> > But all other string literals produce immutable types:
> >
> > ""
> > r""
> > u"" (going away, but still)
> > and hopefully b""
> >
> > Wouldn't it be confusing to have b"" be the only mutable quote-delimited
> > literal?  For everything else, there's bytes().
>
> Well, it would be just as confusing to have a bytes literal and not
> have it return a bytes object. The frozenbytes type is intended (if I
> understand the use case correctly) as for the relatively rare case
> where bytes must be used as dict keys and we can't assume that the
> bytes use any particular encoding.
>
> Personally, I still think that converting to the latin-1 encoding is
> probably just as good for this particular use case. So perhaps I don't
> understand the use case(s?) correctly.
>
> > :-)
>
> What does the :-) mean? That you're not seriously objecting?


No, just that I'm friendly.  (just a smile, not a wink).

I still think that having b"" be the only immutable string-looking thing is
a bad idea.  Just because the types are named "bytes" and "frozenbytes"
instead of "bytes" and "BytesIO" or something similar doesn't mean that the
syntax magically looks right.

--
> --Guido van Rossum (home page: http://www.python.org/~guido/)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20070807/d559048c/attachment.html 


More information about the Python-3000 mailing list