[Python-3000] Immutable bytes type and dbm modules

Jeffrey Yasskin jyasskin at gmail.com
Tue Aug 7 06:26:32 CEST 2007


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:
> > For how long? Do you expect to receive further information that will
> > make a decision simpler?
>
> I'm waiting for a show-stopper issue that can't be solved without
> having an immutable bytes type.

Apologies if this has been answered before, but why are you waiting
for a show-stopper that requires an immutable bytes type rather than
one that requires a mutable one? This being software, there isn't
likely to be a real show-stopper (especially if you're willing to copy
the whole object), just things that are unnecessarily annoying or
confusing. Hashing seems to be one of those.

Taking TOOWTDI as a guideline: If you have immutable bytes and need a
mutable object, just use list(). If you have mutable bytes and need an
immutable object, you could 1) convert it to an int (probably
big-endian), 2) convert it to a latin-1 unicode object (containing
garbage, of course), 3) figure out an encoding in which to assume the
bytes represent text and create a unicode string from that, or 4) use
the deprecated str8 type. Why isn't this a clear win for immutable
bytes?

Jeffrey


More information about the Python-3000 mailing list