numcodecs_wasm

numcodecs compression for codecs compiled to WebAssembly.

numcodecs-wasm provides the WasmCodecMeta meta class to load a codec from a WebAssembly component into a fresh Python class.

Classes:

Functions:

WasmCodecMeta

WasmCodecMeta(clsname, bases, attrs, wasm: bytes)

Bases: type

Meta class to create a Codec class from the WebAssembly component wasm.

Parameters:
  • wasm (bytes) –

    Bytes of the WebAssembly component, from which the class is created.

create_codec_class

create_codec_class(
    module: ModuleType, wasm: bytes
) -> type[Codec]

Create a fresh Codec class from the WebAssembly component wasm. The class will be created into the provided module.

Parameters:
  • module (ModuleType) –

    Module into which the fresh class will be created.

  • wasm (bytes) –

    Bytes of the WebAssembly component, from which the class is created.

Returns:

WasmCodecInstructionCounterObserver

WasmCodecInstructionCounterObserver()

Bases: CodecObserver

Observer that measures the number of executed instructions it takes to encode / decode.

The list of measurements are exposed in the encode_instructions and decode_instructions properties.

encode_instructions property

encode_instructions: Mapping[HashableCodec, list[float]]

Per-codec-instance measurements of the number of executed instructions it takes to encode.

decode_instructions property

decode_instructions: Mapping[HashableCodec, list[float]]

Per-codec-instance measurements of the number of executed instructions it takes to decode.

read_codec_instruction_counter

read_codec_instruction_counter(codec: Codec) -> int

Read the instruction counter of the codec.

Parameters:
  • codec (Codec) –

    The codec whose instruction counter is read.

Returns:
  • instructions( int ) –

    The number of instructions executed by this codec thus far.

Raises:
  • TypeError

    If the codec does not provide an instruction counter.