[Tutor] [Fwd: Re: reading output from a c executable.]

Steve Willoughby steve at alchemy.com
Thu Dec 11 20:34:45 CET 2008


With the amount of information provided so far, I'd say you need to step 
back and question your initial assumptions.  Python shouldn't have a 
great deal of trouble reading variable-length binary data blocks, and 
the overhead of doing that is probably a lot less than it would be to 
have another program read that, output some intermediate format, and 
then have the Python script parse that (and whether you're writing code 
yourself, or blindly eval()ing source created by the C program, or 
reading some other format, it's *still* having to do that).

My recommendation: have the Python script read the binary data directly 
and act upon it, and avoid all the overhead and extra steps you're 
trying to design into your solution here.

If that doesn't run fast enough, consider coding a small file-reading 
module in C, *as a C-implemented Python module*, and import that into 
your program.  But try it in plain Python first and see what it's like.


More information about the Tutor mailing list