Skip to content

Array

async_tiff.Array

Bases: Buffer

A 3D array that implements Python's buffer protocol.

This allows zero-copy interoperability with numpy via np.asarray(arr). The array is immutable and exposes a read-only buffer.

Example:

import numpy as np
from async_tiff import Array

# Create from raw bytes
data = bytes([1, 2, 3, 4, 5, 6])
arr = Array(data, shape=(1, 2, 3), format="<B")  # 1x2x3 uint8 array

# Convert to numpy (zero-copy view)
np_arr = np.asarray(arr)
assert np_arr.shape == (1, 2, 3)
assert np_arr.dtype == np.uint8

shape property

shape: tuple[int, int, int]

The shape of the array.

The interpretation depends on the PlanarConfiguration:

  • PlanarConfiguration=1 (chunky): (height, width, bands)
  • PlanarConfiguration=2 (planar): (bands, height, width)

__buffer__

__buffer__(flags: int) -> memoryview[int]