Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

A high-performance compressed ndarray library with a flexible computational engine

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 a blocking, shuffling and lossless compression library meant for numerical data written in C. Blosc2 is the next generation of Blosc, an award-winning library that has been around for more than a decade, and that is been used by many projects, including PyTables or Zarr.

On top of C-Blosc2 we built Python-Blosc2, a Python wrapper that exposes the C-Blosc2 API, plus many extensions that allow it to work transparently with NumPy arrays, while performing advanced computations on compressed data that can be stored either in-memory, on-disk or on the network (via the Caterva2 library).

Python-Blosc2 leverages both NumPy and numexpr for achieving great performance, but with a twist. Among the main differences between the new computing engine and NumPy or numexpr, you can find:

  • Support for n-dim arrays that are compressed in-memory, on-disk or on the network.

  • High performance compression codecs, for integer, floating point, complex booleans, string and structured data.

  • Can perform many kind of math expressions, including reductions, indexing, filters and more.

  • Support for NumPy ufunc mechanism, allowing to mix and match NumPy and Blosc2 computations.

  • Excellent integration with Numba and Cython via User Defined Functions.

  • Support for broadcasting operations. This is a powerful feature that allows to perform operations on arrays of different shapes.

  • Much better adherence to the NumPy casting rules than numexpr.

  • Lazy expressions that are computed only when needed, and can be stored for later use.

  • Persistent reductions that can be updated incrementally.

  • Support for proxies that allow to work with compressed data on local or remote machines.

You can read some of our tutorials on how to perform advanced computations at:

https://www.blosc.org/python-blosc2/getting_started/tutorials

As well as the full documentation at:

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

Finally, Python-Blosc2 aims to leverage the full C-Blosc2 functionality to support a wide range of compression and decompression needs, including metadata, serialization and other bells and whistles.

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

NDArray: an N-Dimensional store

One of the most useful abstractions in Python-Blosc2 is the NDArray object. It enables highly efficient reading and writing of n-dimensional datasets through a two-level n-dimensional partitioning system. This allows for more fine-grained slicing and manipulation of arbitrarily large and compressed data:

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

To pique your interest, here is how the NDArray object performs when retrieving slices orthogonal to the different axis of a 4-dimensional dataset:

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

We have written a blog post on this topic: https://www.blosc.org/posts/blosc2-ndim-intro

We also have a ~2 min explanatory video on why slicing in a pineapple-style (aka double partition) is useful:

Slicing a dataset in pineapple-style

Operating with NDArrays

The NDArray objects are easy to work with in Python-Blosc2. Here it is a simple example:

import blosc2

N = 20_000  # for small scenario
# N = 50_000 # for large scenario
a = blosc2.linspace(0, 1, N * N).reshape(N, N)
b = blosc2.linspace(1, 2, N * N).reshape(N, N)
c = blosc2.linspace(-10, 10, N * N).reshape(N, N)
# Expression
expr = ((a**3 + blosc2.sin(c * 2)) < b) & (c > 0)

# Evaluate and get a NDArray as result
out = expr.compute()
print(out.info)

As you can see, the NDArray instances are very similar to NumPy arrays, but behind the scenes, they store compressed data that can be processed efficiently using the new computing engine included in Python-Blosc2. [Although not exercised above, broadcasting and reductions also work, as well as filtering, indexing and sorting operations for structured arrays (tables).]

To pique your interest, here is the performance (measured on a modern desktop machine) that you can achieve when the operands in the expression above fit comfortably in memory (20_000 x 20_000):

Performance when operands fit in-memory

In this case, the performance is somewhat below that of top-tier libraries like Numexpr, but it is still quite good, specially when compared with plain NumPy. For these short benchmarks, numba normally loses because its relatively large compiling overhead cannot be amortized.

One important point is that the memory consumption when using the LazyArray.compute() method is pretty low (does not exceed 100 MB) because the output is an NDArray object, which is compressed by default. On the other hand, the LazyArray.__getitem__() method returns an actual NumPy array and hence takes about 400 MB of memory (the 20_000 x 20_000 array of booleans), so using it is not recommended for large datasets, (although it may still be convenient for small outputs, and most specially slices).

Another point is that, when using the Blosc2 engine, computation with compression is actually faster than without it (not by a large margin, but still). To understand why, you may want to read this paper.

And here it is the performance when the operands barely fit in memory (50_000 x 50_000):

Performance when operands do not fit well in-memory

In this latter case, the memory consumption figures does not seem extreme, but this is because the displayed values represent actual memory consumption during the computation (not virtual memory); in addition, the resulting array is boolean, so it does not take too much space to store (just 2.4 GB uncompressed). In this scenario, the performance compared to top-tier libraries like Numexpr or Numba is quite competitive.

You can find the benchmark for the examples above at:

https://github.com/Blosc/python-blosc2/blob/main/bench/ndarray/lazyarray-expr.ipynb

https://github.com/Blosc/python-blosc2/blob/main/bench/ndarray/lazyarray-expr-large.ipynb

Feel free to run them in your own machine and compare the results.

Installing

Blosc2 now provides Python wheels for the major OS (Win, Mac and Linux) and platforms. You can install the binary packages from PyPi using pip:

pip install blosc2

We are in the process of releasing 3.0.0, along with wheels for various versions. For example, to install the first release candidate version, you can use:

pip install blosc2==3.0.0rc2

Documentation

The documentation is available here:

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

Additionally, you can find some examples at:

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

Building from sources

python-blosc2 includes the C-Blosc2 source code and can be built in place:

git clone https://github.com/Blosc/python-blosc2/
cd python-blosc2
pip install .   # add -e for editable mode

That’s it! You can now proceed to the testing section.

Testing

After compiling, you can quickly verify that the package is functioning correctly by running the tests:

pip install .[test]
pytest  (add -v for verbose mode)

Benchmarking

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

python bench/pack_compress.py

License

This software is licensed 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 are welcome on the Blosc mailing list:

blosc@googlegroups.com

https://groups.google.com/g/blosc

Mastodon

Please follow @Blosc2 to stay updated on the latest developments. We recently moved from Twitter to Mastodon.

Thanks

Blosc2 is supported by the NumFOCUS foundation, the LEAPS-INNOV project and ironArray SLU, among many other donors. This allowed the following people have contributed in an important way to the core development of Blosc2:

  • Francesc Alted

  • Marta Iborra

  • Aleix Alcacer

  • Oscar Guiñon

  • Ivan Vilata i Balaguer

  • Oumaima Ech.Chdig

In addition, other people have contributed to the project in different aspects:

  • Jan Sellner, who contributed the mmap support for NDArray/SChunk objects.

  • Dimitri Papadopoulos, who contributed a large bunch of improvements to the in many aspects of the project. His attention to detail is remarkable.

  • Juan David Ibáñez, who contributed different improvements.

  • And many others that have contributed with bug reports, suggestions and improvements.

Citing Blosc

You can cite our work on the various libraries under the Blosc umbrella as follows:

@ONLINE{blosc,
  author = {{Blosc Development Team}},
  title = "{A fast, compressed and persistent data store library}",
  year = {2009-2025},
  note = {https://blosc.org}
}

Donate

If you find Blosc useful and want to support its development, please consider making a donation via the NumFOCUS organization, which is a non-profit that supports many open-source projects. Thank you!

Make compression better!

Metadata

Release files for blosc2 3.0.0rc3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for blosc2 3.0.0rc3
File
blosc2-3.0.0rc3-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
blosc2-3.0.0rc3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
blosc2-3.0.0rc3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details
blosc2-3.0.0rc3-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
blosc2-3.0.0rc3-cp313-cp313-macosx_10_13_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.13+ x86-64 Details
blosc2-3.0.0rc3-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
blosc2-3.0.0rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
blosc2-3.0.0rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
blosc2-3.0.0rc3-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
blosc2-3.0.0rc3-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
blosc2-3.0.0rc3-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
blosc2-3.0.0rc3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
blosc2-3.0.0rc3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
blosc2-3.0.0rc3-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
blosc2-3.0.0rc3-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details

Total release size: 54.5 MB

Release files / blosc2-3.0.0rc3-cp313-cp313-win_amd64.whl

Download URL blosc2-3.0.0rc3-cp313-cp313-win_amd64.whl
Size 2.2 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
128bbfea1581eaf09eb6ab96f4a55c7ff0f23ba0f6709bc59283b8dad40fcb56
BLAKE2b-256 checksum
How to use checksums
4440842624e92a46982cbde731cce71fdf01206fb8b33965d66b8b92cc33996e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL blosc2-3.0.0rc3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.4 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
584de9570aed9ff14e81f7be4b3859eb0c6ba1b2e17f5d47931e6d14d29c352f
BLAKE2b-256 checksum
How to use checksums
d22e9567697d741a1234243fe8bb68dda400fd0b83f34368916b9ba3ab683b50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL blosc2-3.0.0rc3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 4.2 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
31c3010295acad4981f7525261d62a58d2ee57d0f191509405573ac02379ef95
BLAKE2b-256 checksum
How to use checksums
7aee9d0cdb265aed6d77fbd406af8c7265080c3bc88238fded42cda8a4f77eba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp313-cp313-macosx_11_0_arm64.whl

Download URL blosc2-3.0.0rc3-cp313-cp313-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
108ed62794c0fda4753927ad18095df449543bee4b62671740488f93b7b515c8
BLAKE2b-256 checksum
How to use checksums
d6b4ce7054b86c5b6635e9b334d3c13d4afb45f8d7af1496a2c59e888290c375
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp313-cp313-macosx_10_13_x86_64.whl

Download URL blosc2-3.0.0rc3-cp313-cp313-macosx_10_13_x86_64.whl
Size 4.0 MB
Tags CPython 3.13 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
ae9731ae9b3302989fa86de053dc10eb54d59a6293e0850886a8a5812f688d75
BLAKE2b-256 checksum
How to use checksums
a6ee2c4cae395368eff06521b072aa80a5347b2726b905c3f63a47382bb05d80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp312-cp312-win_amd64.whl

Download URL blosc2-3.0.0rc3-cp312-cp312-win_amd64.whl
Size 2.2 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a21785b38095178d3a99adcbfc7c03f1158a6893f019199d4e8fdcea6dd63e47
BLAKE2b-256 checksum
How to use checksums
0bb171be48929e971d396164b126f1c1244e146cf1749b72057aa8fdac3cbfc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL blosc2-3.0.0rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.4 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
75a7f6932f87fe6327426365a2bb47d42f99321424998f43656b6d1ca1360a31
BLAKE2b-256 checksum
How to use checksums
968c1b9a294eef6fc1e080f9bb00a87ceaa0787aac3e84ec41b1417f966d974b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL blosc2-3.0.0rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 4.2 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
50bc753f60cad736c51f05e95148c9fc2fe6817c0532be6a9aff77b5af8128e2
BLAKE2b-256 checksum
How to use checksums
d02047821381dfc22b4cb214e30be76ec2b5e60b4d3c793e0e5fc50f5ccc2a88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp312-cp312-macosx_11_0_arm64.whl

Download URL blosc2-3.0.0rc3-cp312-cp312-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
791b7b646f60470f4e9eb9b52900155dc4fb51e37462db63fb93fa44158ab1af
BLAKE2b-256 checksum
How to use checksums
37c19ece61b6d6998295355d79f696029f115e47746ae720a2c850dc96c5ce39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp312-cp312-macosx_10_13_x86_64.whl

Download URL blosc2-3.0.0rc3-cp312-cp312-macosx_10_13_x86_64.whl
Size 4.0 MB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
a1543bd91be2286f0d7dd2209532cc5db462c92e919534b917ca26fe45eb9346
BLAKE2b-256 checksum
How to use checksums
8a7890c7fca5edb7c02fd2fbf97c34a96bd33fe165999cc5e875bc1e381895d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp311-cp311-win_amd64.whl

Download URL blosc2-3.0.0rc3-cp311-cp311-win_amd64.whl
Size 2.2 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c1d8cc2f45b9141ca3f617610528a0b170b5ff2c09812efc0da44bf6ccff9f56
BLAKE2b-256 checksum
How to use checksums
6bacc7385e56f0417bcc20b50caae9f5861e939e75c0ea954eb7e5f75b756764
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL blosc2-3.0.0rc3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.4 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
43b58c564cd48ec3b65fa43024f320704574451e787eceab5eb0979406d89e44
BLAKE2b-256 checksum
How to use checksums
e86d4fbca4d72e5ca26175485c73d1a09f7f9f2bf9d358ffb2a563852e48e38a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL blosc2-3.0.0rc3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 4.3 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
0b4361f1eab2a43ccb7fb2c0191da51596b8a953cf3b216fe6e4f9f517cf8447
BLAKE2b-256 checksum
How to use checksums
2b6a358bdf00c96db3c8036cc3b88d953b952b9f9725dd97d6ba4397695f75c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp311-cp311-macosx_11_0_arm64.whl

Download URL blosc2-3.0.0rc3-cp311-cp311-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4489c6fac4ce8baff721ecd291c96fd5a725ae60cae76f0e18f5019777a6fb99
BLAKE2b-256 checksum
How to use checksums
0ebf14f23d478575250a7222f916fe96c51049a1993e7939d7a8e78befac3189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / blosc2-3.0.0rc3-cp311-cp311-macosx_10_9_x86_64.whl

Download URL blosc2-3.0.0rc3-cp311-cp311-macosx_10_9_x86_64.whl
Size 4.0 MB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
e89c08b8c6217dce73747685c132c181577343e06925a13c469bf783fa761007
BLAKE2b-256 checksum
How to use checksums
89182ec0a674ef370b0418e431db981a365976fdb906a0de3965a9693c3a83e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release history Release notifications | RSS feed

4.9.1

28 release files

4.9.0

28 release files

4.8.1

28 release files

4.8.0

28 release files

4.7.0

28 release files

4.6.0

28 release files

4.5.1

28 release files

4.5.0

28 release files

4.4.5

26 release files

4.4.4

26 release files

4.4.3

26 release files

4.3.3

31 release files

4.3.1

31 release files

4.3.0

31 release files

4.1.0

31 release files

4.0.0

31 release files

3.9.0

31 release files

3.8.0

31 release files

3.7.2

31 release files

3.7.1

31 release files

3.7.0

31 release files

3.6.1

21 release files

3.6.0

21 release files

3.5.0

21 release files

3.4.0

21 release files

3.3.4

21 release files

3.3.3

21 release files

3.3.1

16 release files

3.2.1

16 release files

3.2.0

16 release files

3.1.1

16 release files

3.1.0

16 release files

3.0.0

16 release files

This release

3.0.0rc3 This release

15 release files

2.7.1

22 release files

2.7.0

22 release files

2.5.1

29 release files

2.5.0

29 release files

2.4.0

29 release files

2.2.8

29 release files

2.2.7

21 release files

2.2.4

21 release files

2.2.3

21 release files

2.2.2

21 release files

2.2.1

21 release files

2.1.1

21 release files

2.1.0

20 release files

2.0.0

21 release files

0.6.6

21 release files

0.6.5

17 release files

0.6.1

21 release files

0.5.2

21 release files

0.5.1

16 release files

0.3.2

16 release files

0.3.1

16 release files

0.1.9

16 release files

0.1.8

16 release files

0.1.7

22 release files

0.1.6

22 release files

0.1.5

22 release files

0.1.4

22 release files

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page