The full description of memoryview can be found here:
Create a
memoryview
that references obj. obj must support the buffer protocol. Built-in objects that support the buffer protocol includebytes
andbytearray
.A
memoryview
has the notion of an element, which is the atomic memory unit handled by the originating object obj. For many simple types such asbytes
andbytearray
, an element is a single byte, but other types such asarray.array
may have bigger elements.
A memoryview is essentially a generalized NumPy array structure in Python itself (without the math). It allows you to share memory between data-structures (things like PIL images, SQLlite data-bases, NumPy arrays, etc.) without first copying. This is very important for large data sets.
With it you can do things like memory-map to a very large file, slice a piece of that file and do calculations on that piece (easiest if you are using NumPy).