[Python-Dev] Changing string constants to byte arrays in Py3k (original) (raw)
Steven Bethard steven.bethard at gmail.com
Sat May 5 18:11:56 CEST 2007
- Previous message: [Python-Dev] Changing string constants to byte arrays in Py3k
- Next message: [Python-Dev] Changing string constants to byte arrays in Py3k
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 5/5/07, M.-A. Lemburg <mal at egenix.com> wrote:
On 2007-05-04 19:51, Guido van Rossum wrote: > [-python-dev] > > On 5/4/07, Fred L. Drake, Jr. <fdrake at acm.org> wrote: >> On Friday 04 May 2007, M.-A. Lemburg wrote: >> > I also suggest making all bytes literals immutable to avoid running >> > into any issues like the above. >> >> +1 from me. > > Rather than adding immutability to bytes objects (which has big > implementation and type checking implications), consider using > buffer(b"123") as an immutable bytes literal. You can freely > concatenate and compare buffer objects with bytes objects.
I like Georg's idea of having an immutable bytes subclass. b"abc" could then be a shortcut constructor for this subclass. In general, I don't think it's a good idea to have literals turn into mutable objects, since literals are normally perceived as being constant.
Does that mean you want list literals to be immutable too?
lst = ['a', 'b', 'c']
lst.append('d') # raises an error?
STeVe
I'm not in-sane. Indeed, I am so far out of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy
- Previous message: [Python-Dev] Changing string constants to byte arrays in Py3k
- Next message: [Python-Dev] Changing string constants to byte arrays in Py3k
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]