Memoryview Attributes

memoryview.c_contiguous

Whether the view has a contiguous C-style layout, with the last dimension varying fastest. 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.c_contiguous

Return Value

bool

Layout flag.

Working Example

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