ListArray

Overview

ListArray is a row-oriented container for variable-length list cells. It is the natural public container for list-valued blosc2.CTable columns, but it is also useful on its own whenever you want typed, row-addressable list data.

Internally, ListArray uses one of two lower-level backends:

Quick example

import blosc2

arr = blosc2.ListArray(
    item_spec=blosc2.string(max_length=16),
    nullable=True,
    storage="batch",
    urlpath="ingredients.b2b",
    mode="w",
)
arr.append(["salt", "sugar"])
arr.append([])
arr.append(None)

print(arr[0])
print(arr[1:])

reopened = blosc2.open("ingredients.b2b", mode="r")
print(type(reopened).__name__)

Note

Returned Python lists are detached values. Mutating them locally does not write back to the container; reassign the whole cell instead.

class blosc2.ListArray(spec: ListSpec | None = None, *, item_spec: SchemaSpec | None = None, nullable: bool = False, storage: str = 'batch', serializer: str = 'msgpack', batch_rows: int | None = None, items_per_block: int | None = None, _from_schunk=None, **kwargs: Any)[source]

A row-oriented container for list-valued data.

Backed internally by either blosc2.ObjectArray or blosc2.BatchArray.

Attributes:
batch_rows
cbytes
contiguous
cparams
cratio
dparams
info
info_items
meta
nbytes
schunk
urlpath
vlmeta

Methods

append

close

copy

extend

flush

from_arrow

to_arrow

to_cframe

Constructors

__init__(spec: ListSpec | None = None, *, item_spec: SchemaSpec | None = None, nullable: bool = False, storage: str = 'batch', serializer: str = 'msgpack', batch_rows: int | None = None, items_per_block: int | None = None, _from_schunk=None, **kwargs: Any) None[source]
classmethod from_arrow(arrow_array, *, item_spec: SchemaSpec | None = None, nullable: bool = True, storage: str = 'batch', serializer: str = 'msgpack', batch_rows: int | None = None, items_per_block: int | None = None, **kwargs: Any) ListArray[source]

Row Interface

__getitem__(index: int | slice | list[int] | tuple[int, ...] | ndarray) Any[source]
__setitem__(index: int, value: Any) None[source]
__len__() int[source]
__iter__() Iterator[Any][source]

Mutation

append(value: Any) int[source]
extend(values: Iterable[Any], *, validate: bool = True) None[source]
flush() None[source]
copy(**kwargs: Any) ListArray[source]
close() None[source]

Context Manager

__enter__() ListArray[source]
__exit__(exc_type, exc_val, exc_tb) bool[source]

Public Members

to_arrow()[source]
to_cframe() bytes[source]