Improved struct module

Markus Stenberg mstenber at cc.Helsinki.FI
Tue Oct 12 06:08:58 EDT 1999


"Tim Peters" <tim_one at email.msn.com> writes:
> 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.

"Speed" springs to my mind; that sounds like something at least I would use
a lot. As a matter of fact, I have my own implementation that is fairly
close to that (cstruct), with main difference being in orientation; mine
accepts C structures (ASCII) as syntax, as opposed to the fairly complex
Python structure xstruct uses for defining the struct.

Only problem is, mine approach is written in Python and seems to be too
slow to be useful for some of the more realtime applications I have (thus,
the reverse problem ;->). Although it is just fairly nasty wrapper around
normal struct module, it performs fairly admirably, except for the CPU
overhead involved. 

If I hadn't to write the C needed, I'd trade the Python code for C code any
day (as a matter of fact, after seeing xstruct I considered writing wrapper
for it instead - trivial task - and using it's C module for my action ;>).

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

-Markus Stenberg

I _wish_ there was a fast Python compiler or something; my fiddling with
Py2C sources (awhile ago) didn't result in very useful speed improvements
without zapping some functionality, but I hope someone'll produce one, one
of these days ;->

-- 
"Schizophrenia, like the Unicorn, is described in various ways by
various people. And its elimination, like the capture of the Unicorn,
appears to require some special conditions, not all of which have yet
been specified. Finally, whether or not those conditions exist, belief
in their existence has had significant consequences."
	- Schizophrenia, Behavioural Aspects (Salzinger, 1972)




More information about the Python-list mailing list