{"id":6550,"library":"blosc","title":"Blosc Data Compressor","description":"Blosc is a high-performance Python wrapper for the C-Blosc meta-compressor library. It's designed for compressing and decompressing numerical datasets, especially those used with NumPy, offering fast, multi-threaded operations. The current version is 1.11.4, and it maintains a regular release cadence, primarily updating its vendored C-Blosc library and supporting newer Python versions.","status":"active","version":"1.11.4","language":"en","source_language":"en","source_url":"https://github.com/blosc/python-blosc","tags":["compression","data","numpy","performance","serialization"],"install":[{"cmd":"pip install blosc","lang":"bash","label":"Install blosc"}],"dependencies":[{"reason":"Recommended for efficient compression/decompression of numerical arrays, though not strictly required for basic bytes operations.","package":"numpy","optional":true}],"imports":[{"symbol":"blosc","correct":"import blosc"},{"symbol":"compress","correct":"from blosc import compress, decompress"},{"symbol":"decompress","correct":"from blosc import compress, decompress"}],"quickstart":{"code":"import blosc\n\ndata_bytes = b\"This is a test string that will be compressed by blosc.\" * 10\n\n# Compress data\n# For byte strings, typesize=1 is appropriate.\n# For NumPy arrays, use typesize=array.itemsize\ncompressed_data = blosc.compress(data_bytes, typesize=1)\nprint(f\"Original size: {len(data_bytes)} bytes\")\nprint(f\"Compressed size: {len(compressed_data)} bytes\")\n\n# Decompress data\ndecompressed_data = blosc.decompress(compressed_data)\n\n# Verify\nassert data_bytes == decompressed_data\nprint(\"Decompression successful!\")\n","lang":"python","description":"Compress and decompress a bytes object. For optimal compression of structured data (e.g., NumPy arrays), ensure `typesize` is set to the item size (e.g., `array.itemsize`)."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. For projects requiring Python 3.7/3.8, pin `blosc<1.11.0` or `blosc<1.11.2` respectively.","message":"Python 3.7 support was dropped in `blosc` 1.11.0, and Python 3.8 support was dropped in 1.11.2.","severity":"breaking","affected_versions":"<1.11.0 (for Python 3.7), <1.11.2 (for Python 3.8)"},{"fix":"Always pass `typesize=array.itemsize` (e.g., `blosc.compress(arr, typesize=arr.itemsize)`) when compressing NumPy arrays or similar structured data.","message":"When compressing structured data like NumPy arrays, setting the `typesize` parameter is crucial for optimal compression ratio and speed. While `typesize=0` works for generic byte streams, it should be set to `array.itemsize` for arrays.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After `decompressed_bytes = blosc.decompress(compressed_data)`, convert using `np.frombuffer(decompressed_bytes, dtype=original_array_dtype)`.","message":"`blosc.decompress()` returns a `bytes` object. When decompressing data that originated from a NumPy array, you must convert this `bytes` object back to a NumPy array manually using `numpy.frombuffer()` with the correct `dtype`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `blosc` version 1.11.4 or newer to ensure full compatibility and avoid warnings with recent NumPy versions.","message":"Version 1.11.4 included fixes for deprecated NumPy usage. Older `blosc` versions might emit warnings or fail when used with newer NumPy versions due to reliance on deprecated NumPy APIs.","severity":"deprecated","affected_versions":"<1.11.4"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}