A contiguous layout places successive data elements at successive memory addresses. For a matrix, this means one dimension is stored contiguously; whether rows or columns are adjacent depends on the layout. section 6.1.2 section 4.1.2
Contiguity affects how efficiently a CPU can reuse fetched data. Reading adjacent elements can let one memory transfer supply several operations, while jumping between distant elements may require repeated transfers. The difference can become pronounced for large matrices, though small ones may fit in cache. section 6.1.2
When working with arrays, account for:
- Traversal order: access neighboring elements in the dimension stored contiguously when optimizing for cache use. section 6.1.2
- Layout convention: C-based code commonly stores rows contiguously, while Fortran-based code commonly stores columns contiguously; NumPy’s backend may use either. section 6.1.2
- Array views: shape and strides describe how an array maps onto memory, and reshaping or transposing can produce views that share memory without implying contiguous access. section 4.1.2
import numpy as np linear = np.arange(10, dtype=np.uint32)
This listing allocates a one-dimensional NumPy array used to illustrate contiguous storage of successive elements. section 4.1.2

