[Python-3000] Immutable bytes type and dbm modules

Guido van Rossum guido at python.org
Tue Aug 7 16:59:05 CEST 2007


On 8/7/07, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Yeah, this approach seems to run counter to the whole point of getting
> rid of the current str type: "for binary data use bytes, for text use
> Unicode, unless you need your binary data to be hashable, and then you
> decode it to gibberish Unicode via the latin-1 codec"
>
> This would mean that the Unicode type would acquire all of the ambiquity
> currently associated with the 8-bit str type: does it contain actual
> text, or does it contain arbitrary latin-1 decoded binary data?

Not necessarily, as this kind of use is typically very localized.
Remember practicality beats purity.

> A separate frozenbytes type (with the bytes API instead of the string
> API) would solve the problem far more cleanly.

But at a cost: an extra data type, more code to maintain, more docs to
write, thicker books, etc.

To me, the most important cost is that every time you need to use
bytes you would have to think about whether to use frozen or mutable
bytes.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list