[Python-3000] Immutable bytes type and dbm modules
Guido van Rossum
guido at python.org
Tue Aug 7 02:19:12 CEST 2007
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:
> 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?
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000