[Python-Dev] sstruct

Just van Rossum just@letterror.com
Tue, 31 Dec 2002 18:46:28 +0100


"Martin v. L=F6wis" wrote:

> Lalo Martins wrote:
> > While idly browsing around, I came across Just's module sstruct.=20
> > Any good reason this is not in the library? =20
>=20
> I can think of two reasons:
> 1. Nobody has proposed to include it, yet.

Including its author ;-)

> 2. It is not obvious that it is useful.
>=20
> On the latter point: What application is finding it so useful that
> they incorporate it in their distribution?

It's incredibly useful in my TrueType/OpenType conversion package
(http://fonttools.sf.net/) where I convert lots of arbitrary and largely
unrelated struct-like data formats to and from Python objects. Having
the field names in the format string and automatically using these for
dict keys or object attribute names was a major win in maintainability
and readability of the code, and it being only a thin layer on top of
the struct module makes it pretty fast.

That said, I was never convinced of a usability so wide as to propose it
for the std lib, and the amount of feedback I got over the years (it's
pretty old!) didn't change that in a positive direction.

The version on sf might be slightly newer than the one on starship (I
don't even know!), but even on sf it hasn't changed since I checked it
in there, three years ago:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/fonttools/fonttools/Lib/
sstruct.py

Just