create a tmp file for system execution
Bengt Richter
bokr at oz.net
Wed May 29 15:54:05 EDT 2002
On Wed, 29 May 2002 15:34:57 +0100, Eric Texier <erict at millfilm.co.uk> wrote:
>I have a py script executing a bunch of os.system in a loop.
>It is not very fast and I was wondering if it will not be better
>to recreate a execution file.
>
>My 2 questions:
>
>1) what is faster for a big number of call
>
>for i in range(1,2000):
> os.system("ls F1.%d F2.%d" % ( i , i ) " )
>
>OR
>
>fileOut = open("tmpFile",w)
>for i in range(1,2000):
> fileOut.write("ls F1.%d F2.%d" % ( i , i ) " )
>
>fileOut.close()
>os.system("csh -c 'source tmpFile' ")
>os.system("rm -f tmpFile")
>
>
>2) if the second one is better I would like to kwo if there is any thing
>
>in python for temporary file, the drag being to if you do not come for
>a specific naming mechanism, you file can be change by and other
>process before it execute
>
wouldn't it be faster to do a single ls F.* command piped to a grep for
the decimal extensions, then to a python script for sorting and final formatting
or whatever you want to do with the file names? Or am I missing something?
Regards,
Bengt Richter
More information about the Python-list
mailing list