PCodec#
- class numcodecs.pcodec.PCodec(level: int = 8, delta_encoding_order: int | None = None, int_mult_spec: Literal['enabled', 'disabled'] = 'enabled', float_mult_spec: Literal['enabled', 'disabled'] = 'enabled', equal_pages_up_to: int = 262144)[source]#
PCodec (or pco, pronounced “pico”) losslessly compresses and decompresses numerical sequences with high compression ratio and fast speed.
See PCodec Repo for more information.
PCodec supports only the following numerical dtypes: uint32, unit64, int32, int64, float32, and float64.
- Parameters:
- levelint
A compression level from 0-12, where 12 take the longest and compresses the most.
- delta_encoding_orderinit or None
Either a delta encoding level from 0-7 or None. If set to None, pcodec will try to infer the optimal delta encoding order.
- int_mult_spec{‘enabled’, ‘disabled’}
If enabled, pcodec will consider using int mult mode, which can substantially improve compression ratio but decrease speed in some cases for integer types.
- float_mult_spec{‘enabled’, ‘disabled’}
If enabled, pcodec will consider using float mult mode, which can substantially improve compression ratio but decrease speed in some cases for float types.
- equal_pages_up_toint
Divide the chunk into equal pages of up to this many numbers.
- codec_id = 'pcodec'#
Codec identifier.
- encode(buf)[source]#
Encode data in buf.
- Parameters:
- bufbuffer-like
Data to be encoded. May be any object supporting the new-style buffer protocol.
- Returns:
- encbuffer-like
Encoded data. May be any object supporting the new-style buffer protocol.
- decode(buf, out=None)[source]#
Decode data in buf.
- Parameters:
- bufbuffer-like
Encoded data. May be any object supporting the new-style buffer protocol.
- outbuffer-like, optional
Writeable buffer to store decoded data. N.B. if provided, this buffer must be exactly the right size to store the decoded data.
- Returns:
- decbuffer-like
Decoded data. May be any object supporting the new-style buffer protocol.