title: Numpy memmap with file deletion
body: <p>Is it possible to have a Numpy memmap file who's file will be deleted when the memmap array is garbage collected?</p>
  
  <p>I have tried:</p>
  
  <pre><code>import tempfile
  import numpy as np
  arr = np.memmap(tempfile.NamedTemporaryFile(), mode='w+',
                  shape=(10, 10), dtype=np.int)
  os.path.exists(arr.filename) # False
  </code></pre>
  
  <p>But it appears the reference to the temporary file isn't kept so is deleted.</p>
  
  <p>I don't want to use a context manager on the temporary file, as I want to be able to return the array from a function and have the file live until the array is no longer used.</p>
  
  <p>NB: similar question here: <a href="https://stackoverflow.com/questions/24178460/in-python-is-it-possible-to-overload-numpys-memmap-to-delete-itself-when-the-m">In Python, is it possible to overload Numpy&#39;s memmap to delete itself when the memmap object is no longer referenced?</a> but the asker exhibits poor knowledge of Python scoping and the tempfile module.</p>