While idly browsing around, I came across Just's module sstruct. Any good reason this is not in the library? It is a kind of cross between struct and ctypes, only a few years more mature. With new-style classes it could probably gain some nifty features. http://starship.python.net/~just/code/sstruct.py []s, |alo +---- -- Those who trade freedom for security lose both and deserve neither. -- http://www.laranja.org/ mailto:lalo@laranja.org pgp key: http://www.laranja.org/pessoal/pgp Eu jogo RPG! (I play RPG) http://www.eujogorpg.com.br/ GNU: never give up freedom http://www.gnu.org/
Lalo Martins wrote:
While idly browsing around, I came across Just's module sstruct. Any good reason this is not in the library?
I can think of two reasons: 1. Nobody has proposed to include it, yet. 2. It is not obvious that it is useful. On the latter point: What application is finding it so useful that they incorporate it in their distribution? Regards, Martin
"Martin v. Löwis" wrote:
Lalo Martins wrote:
While idly browsing around, I came across Just's module sstruct. Any good reason this is not in the library?
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.
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
On Tue, Dec 31, 2002 at 06:46:28PM +0100, Just van Rossum wrote:
"Martin v. Löwis" wrote:
1. Nobody has proposed to include it, yet.
Including its author ;-)
That is why I posted to a forum where I knew said author would read me ;-)
2. It is not obvious that it is useful.
On the latter point: What application is finding it so useful that they incorporate it in their distribution?
Heck, I would have used it instead of struct in all places I ever used struct, if I knew about it before :-) (But the only one of these who is public is the Python client library of the PicoGUI toolkit. It has a heavy dependency on struct, which could be made much more readable with sstruct - actually this is why sstruct got my attention in the first place.) I guess it's essentialy Just's fault for not publicizing his cool stuff better... Perhaps it is not a good time for it to go into 2.3, but I think this is the kind of thing that belongs in the library. It does the same job as struct, but with a more readable (and arguably, pythonic) API. I can volunteer to write the docs and tests, if needed. []s, |alo +---- -- Those who trade freedom for security lose both and deserve neither. -- http://www.laranja.org/ mailto:lalo@laranja.org pgp key: http://www.laranja.org/pessoal/pgp Eu jogo RPG! (I play RPG) http://www.eujogorpg.com.br/ GNU: never give up freedom http://www.gnu.org/
On the latter point: What application is finding it so useful that they incorporate it in their distribution?
Heck, I would have used it instead of struct in all places I ever used struct, if I knew about it before :-)
Can you explain why? Isn't it much slower than struct? Regards, Martin
On Tue, Dec 31, 2002 at 08:38:15PM +0100, "Martin v. Löwis" wrote:
Heck, I would have used it instead of struct in all places I ever used struct, if I knew about it before :-)
Can you explain why? Isn't it much slower than struct?
I haven't yet tested its speed, but Just claims it's just a bit slower. However, in a choice between clarity and speed I almost always, scratch that, always choose clarity. Then *if* I have performance problems I go back and speed up where I can, as long as I don't compromise clarity beyond some reasonable arbitrary limit. The struct module, however, falls a lot beyond this limit, and if I had a choice I wouldn't even have used it at all. (Short answer: Mu.) []s, |alo +---- -- Those who trade freedom for security lose both and deserve neither. -- http://www.laranja.org/ mailto:lalo@laranja.org pgp key: http://www.laranja.org/pessoal/pgp Eu jogo RPG! (I play RPG) http://www.eujogorpg.com.br/ GNU: never give up freedom http://www.gnu.org/
participants (3)
-
"Martin v. Löwis"
-
Just van Rossum
-
Lalo Martins