[Python-ideas] Ideas for improving the struct module

Mark Dickinson dickinsm at gmail.com
Thu Jan 19 03:31:03 EST 2017


On Thu, Jan 19, 2017 at 1:27 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> [...] struct already supports
> variable-width formats.

Unfortunately, that's not really true: the Pascal strings it supports
are in some sense variable length, but are stored in a fixed-width
field. The internals of the struct module rely on each field starting
at a fixed offset, computable directly from the format string. I don't
think variable-length fields would be a good fit for the current
design of the struct module.

For the OPs use-case, I'd suggest a library that sits on top of the
struct module, rather than an expansion to the struct module itself.

-- 
Mark


More information about the Python-ideas mailing list