Internal Organization

Numpy arrays are organized using a set of two parts.

  1. Metadata
  2. Raw array data (or data buffer)

Metadata is the information about the data buffer. It has information about shape, size, data type etc. A numpy array object is the metadata which points to the data buffer.

Any operations on the data buffer results in making new metadata object which points to the same data buffer. This is usually called view of the original array (data buffer). This way, same data buffer can be used for different representation.

However, some numpy operation may return new copy of the data buffer.

References

  1. https://numpy.org/doc/stable/dev/internals.html