[Numpy-discussion] insanely slow writing to memory mapped array

Mathew Yeates myeates at jpl.nasa.gov
Wed Nov 29 19:42:24 CST 2006

I'm trying to duplicate the behavior with a simple program
import numpy


for r in range(0,numrows):
        print r
        big[r,:] = c
        c[r] = 2.0
but it is fast. Hmmm. Any ideas about where to go from here?

Robert Kern wrote:
> Mathew Yeates wrote:
>> Hi
>> I have a line in my program that looks like
>> outarr[1,:] = computed_array
>> where outarr is a memory mapped file. This takes forever.
>> I checked and copying  the data using "cp"  at the command line takes 1 
>> or 2 seconds. So the problem can't be attributed simply to disk i/o. Is 
>> it because the elements are being written one at a time? Any ideas on 
>> how to speed this up?
> Memory-mapping is highly platform dependent. What platform are you on? What are
> the sizes of the arrays? Can you write up a small, self-contained script that
> demonstrates the issue so we can experiment and try things out on different
> machines?

More information about the Numpy-discussion mailing list