0

numpy.memmap initializes with zeros (on systems with POSIX filesystem semantics).

Then how can it take only 0.3 seconds to fill a 10 GB file with zeros like this:

n = 10000000000
f = np.memmap('tmp.mmap', dtype='uint8', mode='w+', shape=(n, 1))
f[-1] = 1  # set some value
del f  # flush changes
f = np.memmap('tmp.mmap', dtype='uint8', mode='r', shape=(n, 1))

Writing 10 GB to disk usually takes longer than 0.3 seconds.

JE_Muc
  • 4,980
  • 2
  • 22
  • 38
root
  • 1,025
  • 8
  • 19

0 Answers0