Having just written yet another module to pack/unpack data into a particular binary format, I'm wondering if someone has a more effective method they'd like to share? I'm thinking some module that can handle RLE/TLV type stuff, complex "encodings" such as utf-8 continued charcters, struct-like pack/unpack for static elements, efficient loading of arrays, and bit-field pack/unpack. Some way to customize handling of a given element within the format (so you could write constraints or what have you), some way to provide defaults, both static and calculated, some way to specify derivative fields, checksums and the like, some way to...
Whenever I look at generalizing this pattern, it always seems to turn into "you should have the equivalent of a compiler/parser-generator" produce this code, but if someone has a good, generic solution, I'd love to hear about it.


Hachoir actually looks sexier for an "out of box" collection of primitives (given it has 70 defined languages already).
Not sure what performance is like, but it looks like I've got some playing to do when I get the time