Memoryview Attributes

memoryview.suboffsets

Inspect the optional indirection metadata for buffers that use pointer-based layouts, such as some image exporters. Ordinary direct buffers generally expose an empty tuple. In an indirect layout, nonnegative entries specify an offset after pointer dereferencing; negative entries indicate no dereference for the corresponding axis. This read-only metadata is informational and should not be treated as ordinary strides. Examples and tests use direct exporters only; indirect exporters are not locally exercised.

Formal Syntax & Structure

python syntaxpython
view.suboffsets

Return Value

tuple[int, ...]

Indirect-layout metadata, or an empty tuple for ordinary direct buffers.

Working Example

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