BlobArray¶
- class dsviper.BlobArray(blob_layout, blob)¶
Bases:
objectReads blob as a flat array of blob_layout.data_type.
The blob must hold a whole number of elements - its size a multiple of blob_layout.byte_count() - or the constructor raises.
The binary reading of a blob: an index answers one datum, as a native scalar, and the buffer protocol hands out the bytes read-only. Use BlobView to read the same bytes element by element.
len() and iteration walk the data as well, so they answer blob_layout.components() times what BlobView.count() reports over the same bytes.
numpy.asarray() over it IS that buffer: the dtype follows blob_layout.data_type with nothing to declare, the array is a read-only view sharing the blob’s bytes rather than a copy, and reshape(-1, blob_layout.components()) gives the elements without copying either.
A BlobArrayBuilder writes the bytes a blob is sealed with.
- blob_layout() BlobLayout¶
Return the BlobLayout of one element: its data type and how many components it packs.
- blob_view() BlobView¶
Return a BlobView over the same bytes, indexed by element rather than by data.
- data_count() int¶
Return how many data the array holds, which len() also answers: an element packs blob_layout.components() data, and an index addresses one datum.