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
  • 5,403
  • 2
  • 26
  • 41
root
  • 1,812
  • 1
  • 12
  • 26

0 Answers0