Am Freitag, 16. Januar 2009 13:02:59 schrieb Alfons Nonell-Canals: > Hello, > I'm developing a software package using python. I've programmed all > necessary tools but I have to use other stuff from other people. Most of > these external scripts are developed using awk. > > At the beggining I thought to "translate" them and program > them in python but I prefer to avoid it because it means a lot > of work and I should do it after each new version of this > external stuff. I would like to integrate them into my python > code. > > I know I can call them using the system environment but it is > slower than if I call them inside the package.
So you've tried system(), and it didn't meet your requirements? > I know it is possible with C, What is possible with C? > do you have experience on integrate awk into python calling > these awk scripts from python? Just like in C, you can call them directory using fork/exec to eliminate the shell spawned by system(), but the difference in time is probably going to be negligible. If you're not able to meet your timing requirements using os.system(), then I suspect it's the awk programs that are too slow. I'd probably use the subprocess module to avoid the shell for security reasons. First, get it working. Then, after you've established that the program isn't meeting the timing specification _measure_ where the time is going. It's silly trying optimize the part of the program that's only taking up 1% of the execution time. "Premature optimization..." -- Grant Edwards grante Yow! They collapsed at ... like nuns in the visi.com street ... they had no teen appeal! -- http://mail.python.org/mailman/listinfo/python-list