> 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4