Write 10k integers to a file using struct

Josiah Carlson jcarlson at uci.edu
Tue Oct 26 16:36:33 EDT 2004


Thomas <2002 at weholt.org> wrote:
> What's the quickest way to write and read 10.000 integer values ( or
> more )  to and from a file? Using struct somehow? The example in the
> docs shows how to handle to or three arguments, but is the fastest way
> to write and read just a simple :
> 
> while data:
> 	f.write(struct.pack(format, integer-value))
> 
> or is there another, quicker and nicer way to do it????

Look at the array module.

 - Josiah




More information about the Python-list mailing list