[SciPy-user] What is fastest load/save matrix methods?

Travis Oliphant oliphant at ee.byu.edu
Mon Dec 19 23:18:27 CST 2005

Hugo Gamboa wrote:

>Hi there,
>I need to work with large matrixes that come in ascii format.
>I have the functions to build the matrix from the ascii file but it 
>takes too long.
>I can spend some time convert ingthis ascii files to some other format 
>so that the re-readeing be fastened.
Look at the tofile method of scipy arrays and the fromfile function.

You can read and write simple ascii files.

But, the fastest approach would be to convert to (native) binary files 
and then read them using fromfile.   (Actually, depending on what you 
are doing, the fastest approach may be to use a memory-mapped array). 

The tofile and fromfile approaches are very raw and you must understand 
the data on the disk.  But, because of that, they would be the fastest, 
I think.


More information about the SciPy-user mailing list