Memoryview Attributes

memoryview.contiguous

Whether the view is contiguous in either C or Fortran order. A normal dense one-dimensional buffer is both C- and F-contiguous. A multi-element stepped or reversed view may be neither. Dimensions of size one can make both flags true even in multidimensional views. Contiguity is about layout, not writability. This attribute is read-only.

Formal Syntax & Structure

python syntaxpython
view.contiguous

Return Value

bool

Layout flag.

Working Example

Example Snippetpython
flat = memoryview(b"ABCDEF")matrix = flat.cast("B", [2, 3])print(flat.contiguous, matrix.contiguous)print(flat[::2].contiguous)
Python Reference