title: NumPy Array Copy-On-Write
body: <p>I have a class that returns large NumPy arrays. These arrays are cached within the class. I would like the returned arrays to be copy-on-write arrays. If the caller ends up just reading from the array, no copy is ever made. This will case no extra memory will be used. However, the array is "modifiable", but does not modify the internal cached arrays.</p>
  
  <p>My solution at the moment is to make any cached arrays readonly <code>(a.flags.writeable = False)</code>. This means that if the caller of the function may have to make their own copy of the array if they want to modify it. Of course, if the source was not from cache and the array was already writable, then they would duplicate the data unnecessarily.</p>
  
  <p>So, optimally I would love something like <code>a.view(flag=copy_on_write)</code>. There seems to be a flag for the reverse of this <code>UPDATEIFCOPY</code> which causes a copy to update the original once deallocated.</p>
  
  <p>Thanks!</p>