If you have a lot of arrays to save data , And check and calculate , Then you have to be familiar with memorview Use , Otherwise, you will lead to inefficient data processing .
memorview Class is a class that shares memory data , When you use it to slice arrays , You don't need to copy the data to see . therefore , It is widely used in NumPy garage .memoryview Essentially, Python One of its own NumPy Array structure . It allows you to share memory between data structures （ such as PIL Images 、SQLlite database 、NumPy Array etc. ）, No need to pre copy . This is very important for large datasets .
memoryview Use and array The module is similar to , however memoryview You can do data type conversion , similar C In languages, cast types . Take the following example ：
>>> numbers = array.array('h', [-2, -1, 0, 1, 2])
>>> memv = memoryview(numbers)