Skip to main content

Python wrapper for the C-Blosc2 library.

Project description

A Python wrapper for the extremely fast Blosc2 compression library

Author:

The Blosc development team

Contact:

blosc@blosc.org

Github:

https://github.com/Blosc/python-blosc2

Actions:

actions

PyPi:

version

NumFOCUS:

numfocus

Code of Conduct:

Contributor Covenant

What it is

C-Blosc2 is the new major version of C-Blosc, and is backward compatible with both the C-Blosc1 API and its in-memory format.

Python-Blosc2 is a Python package that wraps C-Blosc2, the newest version of the Blosc compressor. Currently Python-Blosc2 already reproduces the API of Python-Blosc, so it can be used as a drop-in replacement. However, there are a few exceptions for a full compatibility.

In addition, Python-Blosc2 aims to leverage the new C-Blosc2 API so as to support super-chunks, multi-dimensional arrays (NDArray), serialization and other bells and whistles introduced in C-Blosc2. Although this is always and endless process, we are have almost catched up with the full C-Blosc2 potential (with the convenience of Python :-).

Note: Python-Blosc2 is meant to be backward compatible with Python-Blosc data. That means that it can read data generated with Python-Blosc, but the opposite is not true (i.e. there is no forward compatibility).

NDArray: an N-Dimensional store

One of the latest and more exciting additions in Python-Blosc2 is the NDArray object. It can write and read n-dimensional datasets in an extremely efficient way thanks to a n-dim 2-level partitioning, allowing to slice and dice arbitrary large and compressed data in a more fine-grained way:

https://github.com/Blosc/python-blosc2/blob/main/images/b2nd-2level-parts.png?raw=true

To wet you appetite, here it is how the NDArray object performs on getting slices orthogonal to the different axis of a 4-dim dataset:

https://github.com/Blosc/python-blosc2/blob/main/images/Read-Partial-Slices-B2ND.png?raw=true

We have blogged about this: https://www.blosc.org/posts/blosc2-ndim-intro

We also have a explanatory video on why the double partition is useful (~2 min).

Installing

Blosc is now offering Python wheels for the main OS (Win, Mac and Linux) and platforms. You can install binary packages from PyPi using pip:

pip install blosc2

Documentation

The documentation is here:

https://blosc.org/python-blosc2/python-blosc2.html

Also, some examples are available on:

https://github.com/Blosc/python-blosc2/tree/main/examples

Building from sources

python-blosc2 comes with the C-Blosc2 sources with it and can be built in-place:

git clone https://github.com/Blosc/python-blosc2/
cd python-blosc2
git submodule update --init --recursive
python -m pip install -r requirements-build.txt
python setup.py build_ext --inplace

That’s all. You can proceed with testing section now.

Testing

After compiling, you can quickly check that the package is sane by running the tests:

python -m pip install -r requirements-tests.txt
python -m pytest  (add -v for verbose mode)

Benchmarking

If curious, you may want to run a small benchmark that compares a plain NumPy array copy against compression through different compressors in your Blosc build:

PYTHONPATH=. python bench/pack_compress.py

License

The software is licenses under a 3-Clause BSD license. A copy of the python-blosc2 license can be found in LICENSE.txt.

Mailing list

Discussion about this module is welcome in the Blosc list:

blosc@googlegroups.com

https://groups.google.es/group/blosc

Twitter

Please follow @Blosc2 to get informed about the latest developments.


Enjoy data!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blosc2-2.1.1.tar.gz (4.3 MB view hashes)

Uploaded Source

Built Distributions

blosc2-2.1.1-cp311-cp311-win_amd64.whl (2.2 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

blosc2-2.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

blosc2-2.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

blosc2-2.1.1-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

blosc2-2.1.1-cp311-cp311-macosx_10_9_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

blosc2-2.1.1-cp310-cp310-win_amd64.whl (2.2 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

blosc2-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

blosc2-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

blosc2-2.1.1-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

blosc2-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

blosc2-2.1.1-cp39-cp39-win_amd64.whl (2.2 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

blosc2-2.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

blosc2-2.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

blosc2-2.1.1-cp39-cp39-macosx_11_0_arm64.whl (3.3 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

blosc2-2.1.1-cp39-cp39-macosx_10_9_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

blosc2-2.1.1-cp38-cp38-win_amd64.whl (2.2 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

blosc2-2.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

blosc2-2.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

blosc2-2.1.1-cp38-cp38-macosx_11_0_arm64.whl (3.3 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

blosc2-2.1.1-cp38-cp38-macosx_10_9_x86_64.whl (4.2 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page