[Python-Dev] an idea for improving struct.unpack api (original) (raw)
Michael Hudson mwh at python.net
Fri Jan 7 15:07:21 CET 2005
- Previous message: [Python-Dev] an idea for improving struct.unpack api
- Next message: [Python-Dev] an idea for improving struct.unpack api
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bob Ippolito <bob at redivi.com> writes:
On Jan 6, 2005, at 8:17, Michael Hudson wrote:
Ilya Sandler <ilya at bluefir.net> writes:
A problem:
The current struct.unpack api works well for unpacking C-structures where everything is usually unpacked at once, but it becomes inconvenient when unpacking binary files where things often have to be unpacked field by field. Then one has to keep track of offsets, slice the strings,call struct.calcsize(), etc... IMO (and E), struct.unpack is the primitive atop which something more sensible is built. I've certainly tried to build that more sensible thing at least once, but haven't ever got the point of believing what I had would be applicable to the general case... maybe it's time to write such a thing for the standard library. This is my ctypes-like attempt at a high-level interface for struct. It works well for me in macholib: http://svn.red-bean.com/bob/py2app/trunk/src/macholib/ptypes.py
Unsurprisingly, that's fairly similar to mine :)
Cheers, mwh
-- If trees could scream, would we be so cavalier about cutting them down? We might, if they screamed all the time, for no good reason. -- Jack Handey
- Previous message: [Python-Dev] an idea for improving struct.unpack api
- Next message: [Python-Dev] an idea for improving struct.unpack api
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]