Most efficient way to write data out to a text file?

Peter Hansen peter at
Wed Jun 26 23:56:09 EDT 2002

candiazoo at wrote:
> I assume some sort of block i/o or preallocating a large block of file space
> would be the best way to do it?  I am outputting about 700,000 records to a text
> file and my program only spits out about 20 records per second.  This is using
> standard file open and write...

You're not opening and closing the file for each record that is written, are you?

Can you post more detail on the amount of data in a record, and the format?

Why not profile the code using the module and actually see
where the problem is?


More information about the Python-list mailing list