in reply to Speed of opening and closing a file 1000s times
Iterating through the same infile multiple times so as to be able to keep only one file opened at a time is a wasteful design, as is opening and immediately closing each outfile every time it is decided that something should be written to it. Open them all, do your work quickly, and then once you're done iterating, close them all.
I wonder if your reason for wanting to open and immediately close each file was to circumvent the need for proper file locking. If so, that too is a seriously flawed design in an environment where the files may be needed by multiple processes.
Dave
|
|---|