PCodec#
- class numcodecs.pcodec.PCodec(level: int = 8, delta_encoding_order: int | None = None, equal_pages_up_to: int = 262144, mode_spec: Literal['auto', 'classic'] = 'auto')[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: uint16, uint32, uint64, int16, int32, int64, float16, 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.
- mode_spec{‘auto’, ‘classic’}
Configures whether Pcodec should try to infer the best “mode” or structure of the data (e.g. approximate multiples of 0.1) to improve compression ratio, or skip this step and just use the numbers as-is (Classic mode).
- 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.