[Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer (original) (raw)
Guido van Rossum guido at python.org
Fri Sep 28 16:47:45 CEST 2007
- Previous message: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer
- Next message: [Python-3000] Python, int/long and GMP
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 9/28/07, Joel Bender <jjb5 at cornell.edu> wrote:
Should this PEP include changes to the struct module, or should it be a separate PEP?
Neither.
I would like struct.pack() to return bytes and struct.unpack() to accept bytes or buffers but not strings.
This is already the case in 3.0a1. (Don't people try stuff out before posting?)
The 's' and 'p' format specifier should refer to bytes and not strings.
They currently allow both, which I think is fine.
In protocol encoding and decoding, "unpack and strip off the front" and "pack and append" are very common operations. I would also like to have buffer.unpack(fmt) be the former and buffer.pack(fmt, v1, v2, ...) be the latter.
IMO that would tie the buffer type too close to the struct module. You could easily write a wrapper that does this though.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer
- Next message: [Python-3000] Python, int/long and GMP
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]