[Python-Dev] an idea for improving struct.unpack api (original) (raw)
Anthony Baxter anthony at interlink.com.au
Thu Jan 6 11:28:26 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 ]
My take on this:
struct.pack/struct.unpack is already one of my least-favourite parts
of the stdlib. Of the modules I use regularly, I pretty much only ever
have to go back and re-read the struct (and re) documentation because
they just won't fit in my brain. Adding additional complexity to them
seems like a net loss to me.
I'd _love_ to find the time to write a sane replacement for struct - as
well as the current use case, I'd also like it to handle things like
attribute-length-value 3-tuples nicely (where you get a fixed field
which identifies the attribute, a fixed field which specifies the value
length, and a value of 'length' bytes). Almost all sane network protocols
(i.e. those written before the plague of pointy brackets) use this in
some way.
I'd much rather specify the format as something like a tuple of values -
(INT, UINT, INT, STRING) (where INT &c are objects defined in the
struct module). This also then allows users to specify their own formats
if they have a particular need for something.
Anthony
Anthony Baxter <anthony at interlink.com.au> It's never too late to have a happy childhood.
- 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 ]