NumPy Array Copy-On-Write
问题 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. My solution at the moment is to make any cached arrays readonly (a.flags.writeable = False) . This means that if the caller of the function may