Improved struct module

Tim Peters tim_one at email.msn.com
Tue Oct 12 00:35:51 EDT 1999


[Robin Boerdijk]
> I would like to make a case for replacing the current Python
> struct module with an improved version of it. I think the
> struct module contains very useful functionality, but the
> interface functions (pack and unpack) are inconvenient
> for a number of situations.
>
> To fix the pack/unpack inconvenience, I have written an xstruct
> module that extends the struct module with a new structdef
> function to *define* packed binary data structures (similar to
> C's struct keyword).
>
> [and code & docs are at
>      http://www.sis.nl/python/xstruct/xstruct.html
> ]

The xstruct interface is nice.  Why is it implemented in C?  That is, it
seems to combine two things:  random improvements to the std struct module's
internals, and a new interface.  The latter is much easier to do and
maintain if written in Python, and would also be sub-classable then.  You
should try to get the "random improvements" into the std struct module
regardless; the new interface would likely have a better chance as 100 new
lines of Python than as 800-900 new lines of C.

guido-gets-so-c-sick-i-tell-you-he-vomits<wink>-ly y'rs  - tim






More information about the Python-list mailing list