Compression Utilities

Although using NDArray/SChunk objects is the recommended way to work with Blosc2 data, there are some utilities that allow you to work with Blosc2 data in a more low-level way. This is useful when you need to work with data that is not stored in NDArray/SChunk objects, or when you need to work with data that is stored in a different format.

This API is meant to be compatible with the existing python-blosc API. There could be some parameters that are called differently, but other than that, they are largely compatible. In addition, there are some new functions that are not present in the original python-blosc API that are mainly meant to overcome the 2 GB limit that the original API had.

Compress and decompress

compress(src[, typesize, clevel, filter, codec])

Compress the given source data with specified parameters.

compress2(src, **kwargs)

Compress the given src buffer with the specified compression parameters.

decompress(src[, dst, as_bytearray])

Decompresses a bytes-like compressed object.

decompress2(src[, dst])

Decompress the given src buffer with the specified decompression params.

pack(obj[, clevel, filter, codec])

Pack (compress) a Python object.

pack_array(arr[, clevel, filter, codec])

Pack (compress) a NumPy array.

pack_array2(arr[, chunksize])

Pack (compress) a NumPy array.

pack_tensor(tensor[, chunksize])

Pack (compress) a TensorFlow or PyTorch tensor or a NumPy array.

unpack(packed_object, **kwargs)

Unpack (decompress) an object.

unpack_array(packed_array, **kwargs)

Restore a packed NumPy array.

unpack_array2(cframe)

Unpack (decompress) a packed NumPy array from a cframe.

unpack_tensor(cframe)

Unpack (decompress) a packed TensorFlow or PyTorch tensor or a NumPy array from a cframe.

Set / get compression params

clib_info(codec)

Return information about the compression libraries in the C library.

compressor_list([plugins])

Returns a list of compressors (codecs) available in the C library.

detect_number_of_cores()

Detect the number of cores in this system.

free_resources()

Free any temporary memory and thread resources.

get_clib(bytesobj)

Return the name of the compression library for Blosc bytesobj buffer.

nthreads

Number of threads to be used in compression/decompression.

print_versions()

Print all the versions of software that python-blosc2 relies on.

register_codec(codec_name, id[, encoder, ...])

Register a user defined codec.

register_filter(id[, forward, backward, name])

Register a user-defined filter.

set_blocksize([blocksize])

Force the use of a specific blocksize.

set_nthreads(nthreads)

Set the number of threads to be used during Blosc operations.

set_releasegil(gilstate)

Set whether to release the Python global inter-lock (GIL) during c-blosc compress and decompress operations or not.

set_compressor(codec)

Set the compressor to be used.

get_compressor()

Get the current compressor used for compression.

get_blocksize()

Get the internal blocksize to be used during compression.

get_cbuffer_sizes(src)

Get the sizes of a compressed src buffer.

cparams_dflts

dparams_dflts

storage_dflts

Enumerated classes

Codec(value[, names, module, qualname, ...])

Available codecs.

Filter(value[, names, module, qualname, ...])

Available filters.

SpecialValue(value[, names, module, ...])

Possible special values in a chunk.

SplitMode(value[, names, module, qualname, ...])

Available split modes.

Tuner(value[, names, module, qualname, ...])

Available tuners.

Utils

compute_chunks_blocks(shape[, chunks, ...])

Compute educated guesses for chunks and blocks of a NDArray.

get_slice_nchunks(schunk, key)

Get the unidimensional chunk indexes needed to obtain a slice of a SChunk or a NDArray.

remove_urlpath(path)

Permanently remove the file or the directory specified by path.

Utility variables

blosclib_version

The blosc2 version + date.

DEFINED_CODECS_STOP

Maximum possible Blosc2-defined codec id.

GLOBAL_REGISTERED_CODECS_STOP

Maximum possible Blosc2 global registered codec id.

USER_REGISTERED_CODECS_STOP

Maximum possible Blosc2 user registered codec id.

EXTENDED_HEADER_LENGTH

Blosc2 extended header length in bytes.

MAX_BUFFERSIZE

Maximum buffer size in bytes for a Blosc2 chunk.

MAX_BLOCKSIZE

int([x]) -> integer int(x, base=10) -> integer

MAX_OVERHEAD

Maximum overhead during compression (in bytes).

MAX_TYPESIZE

Blosc2 maximum type size (in bytes).

MIN_HEADER_LENGTH

Blosc2 minimum header length (in bytes).

prefilter_funcs

Registry for prefilter functions.

postfilter_funcs

Registry for postfilter functions.

ucodecs_registry

Registry for user-defined codecs.

ufilters_registry

Registry for user-defined filters.

VERSION_DATE

The C-Blosc2 version's date.

VERSION_STRING

The C-Blosc2 version's string.

__version__

Python-Blosc2 version.