code: def ndarray_fs(shape, dtype, location, lock, readonly=False, order='F', **kwargs):
    
    dbytes = np.dtype(dtype).itemsize
    nbytes = Vec(*shape).rectVolume() * dbytes
    directory = mkdir(EMULATED_SHM_DIRECTORY)
    filename = os.path.join(directory, location)
  
    if lock:
      lock.acquire()
  
    exists = os.path.exists(filename)
    size = 0 if not exists else os.path.getsize(filename)
  
    if readonly and not exists:
      raise SharedMemoryReadError(filename + " has not been allocated. Requested " + str(nbytes) + " bytes.")
    elif readonly and size != nbytes:
      raise SharedMemoryReadError("{} exists, but the allocation size ({} bytes) does not match the request ({} bytes).".format(
        filename, size, nbytes
      ))
  
    if exists: 
      if size > nbytes:
        with open(filename, 'wb') as f:
          os.ftruncate(f.fileno(), nbytes)
      elif size < nbytes:
        # too small? just remake it below
        # if we were being more efficient
        # we could just append zeros
        os.unlink(filename) 
  
    exists = os.path.exists(filename)
  
    if not exists:
      blocksize = 1024 * 1024 * 10 * dbytes
      steps = int(math.ceil(float(nbytes) / float(blocksize)))
      total = 0
      with open(filename, 'wb') as f:
        for i in range(0, steps):
          write_bytes = min(blocksize, nbytes - total)
          f.write(b'\x00' * write_bytes)
          total += blocksize
  
    if lock:
      lock.release()
  
    with open(filename, 'r+b') as f:
      array_like = mmap.mmap(f.fileno(), 0) # map entire file
    
    renderbuffer = np.ndarray(buffer=array_like, dtype=dtype, shape=shape, order=order, **kwargs)
    renderbuffer.setflags(write=(not readonly))
    return array_like, renderbuffer
docs: Emulate shared memory using the filesystem.