BlobView

class dsviper.BlobView(blob_layout, blob)

Bases: object

Interprets the bytes of a blob through its layout.

len() and indexing walk ELEMENTS: view[i] answers one element - a native scalar when the layout packs one component, a ValueVec of blob_layout.components() values otherwise - and iterating yields the same. BlobArray reads the same bytes one datum at a time.

The blob must hold a whole number of elements - its size a multiple of blob_layout.byte_count() - or the constructor raises.

blob() → ValueBlob

Return the ValueBlob the view reads. The bytes are shared, not copied.

blob_layout() → BlobLayout

Return the BlobLayout of one element: its data type and how many components it packs.

count() → int

Return the number of elements in the blob.

data_count() → int

Return the number of data in the blob - count() elements of as many components as the layout packs.

encoder_layout() → BlobEncoderLayout

Return the BlobEncoderLayout: the blob layout together with the Viper types an element and a component decode to.