PCodec#
- class numcodecs.pcodec.PCodec(level: int = 8, *, mode_spec: Literal['auto', 'classic'] = 'auto', delta_spec: Literal['auto', 'none', 'try_consecutive', 'try_lookback'] = 'auto', paging_spec: Literal['equal_pages_up_to'] = 'equal_pages_up_to', delta_encoding_order: int | None = None, 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: 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.
- 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). Note that the “try*” specs are not currently supported.
- delta_spec{“auto”, “none”, “try_consecutive”, “try_lookback”}
Configures the delta encoding strategy. By default, uses “auto” which will try to infer the best encoding order.
- paging_spec{“equal_pages_up_to”}
Configures the paging strategy. Only “equal_pages_up_to” is currently supported.
- delta_encoding_orderint or None
Explicit delta encoding level from 0-7. Only valid if delta_spec is “try_consecutive” or “auto” (to support backwards compatibility with older versions of this codec).
- equal_pages_up_toint
Divide the chunk into equal pages of up to this many numbers.
- codec_id: str | None = '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.