[Python-Dev] new buffer in python2.7 (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Fri Oct 29 12:15:04 CEST 2010
- Previous message: [Python-Dev] new buffer in python2.7
- Next message: [Python-Dev] new buffer in python2.7
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Actually I would like code like s = socket() ... header = struct.unpack("i", s)
In other words, struct should interact with files/streams directly, instead of requiring me to first read a chunk who's size I manually have to determine etc.
That is easy to achieve using the existing API:
def read_and_unpack(stream, format): data = stream.read(struct.calcsize(format)) return struct.unpack(format, data)
Otherwise, I'm +1 on your suggestion, avoiding copying is a good thing.
I believe my function also doesn't involve any unnecessary copies.
Regards, Martin
- Previous message: [Python-Dev] new buffer in python2.7
- Next message: [Python-Dev] new buffer in python2.7
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]