{"id":973,"library":"blis","title":"Blis BLAS-like Linear Algebra Library","description":"Blis is a Python library that provides a high-performance, self-contained C-extension for BLAS-like dense linear algebra operations. Developed by Explosion (the creators of spaCy), it focuses on delivering fast matrix multiplication and other linear algebra routines without requiring external system dependencies. The library is actively maintained, with a current version of 1.3.3, and releases often include support for newer Python versions and updates to underlying dependencies like NumPy.","status":"active","version":"1.3.3","language":"python","source_language":"en","source_url":"https://github.com/explosion/cython-blis","tags":["linear-algebra","blas","numpy","cython","performance","machine-learning"],"install":[{"cmd":"pip install blis","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for array handling and integration with the Python numerical ecosystem.","package":"numpy","optional":false}],"imports":[{"note":"Provides a high-level Python API for Einstein summation, similar to NumPy's einsum but optimized for Blis routines.","symbol":"einsum","correct":"from blis.py import einsum"},{"note":"Used for direct Cython access, offering fused-type, nogil bindings to the underlying Blis library.","symbol":"cy","correct":"cimport blis.cy"}],"quickstart":{"code":"import numpy as np\nfrom blis.py import einsum\n\ndim_a, dim_b, dim_c = 500, 128, 300\n\narr1 = np.random.rand(dim_a, dim_b).astype('float32')\narr2 = np.random.rand(dim_b, dim_c).astype('float32')\nout = np.zeros((dim_a, dim_c), dtype='float32')\n\n# Perform matrix multiplication using einsum\neinsum('ab,bc->ac', arr1, arr2, out=out)\n\nprint(f\"Output shape: {out.shape}\")\n# Example of returning a new array with transposed output\nout_transposed = einsum('ab,bc->ca', arr1, arr2)\nprint(f\"Transposed output shape: {out_transposed.shape}\")","lang":"python","description":"This quickstart demonstrates how to use the high-level `einsum` function from `blis.py` for efficient matrix multiplication. It uses NumPy arrays as input and output, showcasing how Blis integrates with the NumPy ecosystem. The `einsum` function supports various tensor operations with specific restrictions that allow direct mapping to optimized Blis routines. Ensure NumPy is installed as a dependency."},"warnings":[{"fix":"Ensure your project's `blis` installation and any dependent packages are built against NumPy 2.x for maximum compatibility. If you are building from source, this will typically happen automatically when NumPy 2.x is present. Downstream projects using `blis` should verify their build processes with NumPy 2.x.","message":"Blis versions 1.0.0 and later introduce a breaking change due to dependency on NumPy 2.0. Wheels built against NumPy 1.x are not compatible with NumPy 2.0. If you distribute binaries, they must be built against NumPy 2.x to be compatible with both NumPy 1.x and 2.x runtimes.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"If experiencing poor performance on specific hardware, refer to the `blis` GitHub repository documentation on 'Building BLIS for alternative architectures' and install using `BLIS_ARCH=\"your_arch\" pip install blis --no-binary blis`.","message":"For optimal performance on non-x86_64 or osx/arm64 architectures, you may need to compile `blis` from source with specific architecture flags. The provided wheels are optimized for common architectures, but for other CPUs, a generic (slower) build might be used unless `BLIS_ARCH` environment variable is set during installation.","severity":"gotcha","affected_versions":"all"},{"fix":"Avoid concurrent mutation of NumPy arrays used as input to Blis operations across multiple threads. Ensure data is immutable during Blis computations or manage threading carefully at a higher level.","message":"Blis is designed for single-threaded execution for its intended workloads (ML inference). While it is re-entrant and safe to use concurrently from multiple threads with immutable data, concurrent mutation of input NumPy arrays from different threads while Blis is running can lead to data races or segmentation faults.","severity":"gotcha","affected_versions":"all"},{"fix":"Users on Windows encountering instability should upgrade to `blis` version `1.2.0` or newer.","message":"Earlier versions around `v1.0.0` experienced memory access errors and instability on Windows. This issue was addressed in `v1.2.0` by reverting to an older, more stable version of the vendored Blis library.","severity":"gotcha","affected_versions":">=1.0.0, <1.2.0"},{"fix":"Ensure a C compiler is installed and accessible in your environment. On Debian/Ubuntu systems, install `build-essential` (`apt-get install build-essential`). On macOS, install Xcode Command Line Tools (`xcode-select --install`). On Windows, install Microsoft Visual C++ Build Tools.","message":"Building `blis` from source requires a C compiler (e.g., `gcc` on Linux, Clang/Xcode on macOS, MSVC on Windows). If a pre-built wheel is not available for your platform and Python version, or if you explicitly request a source build, compilation will fail without a suitable compiler installed.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T21:59:32.350Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Install necessary build tools for your operating system (e.g., 'build-essential' on Linux, 'Microsoft Visual C++ Build Tools' on Windows) and ensure `pip`, `setuptools`, and `wheel` are up-to-date. For specific architectures, you might need to set the `BLIS_ARCH` environment variable before installing (e.g., `BLIS_ARCH='generic' pip install --no-binary blis`). Alternatively, use `conda install -c conda-forge blis` if using Anaconda/Miniconda, as it often handles binary dependencies more effectively.","cause":"This error indicates that `pip` failed to compile the `blis` library from its source code, often due to missing C/C++ build tools on the system or architectural incompatibilities when pre-compiled wheels are not available.","error":"ERROR: Failed building wheel for blis"},{"fix":"Ensure `blis` is installed in your active Python environment using `pip install blis`. If you have multiple Python versions, confirm you are using the `pip` associated with the correct Python interpreter. If bundling your application (e.g., with Nuitka), check the documentation for how to include C extensions or specific packages.","cause":"This error occurs when the Python interpreter cannot find the `blis` module, either because it was not successfully installed, is installed in a different Python environment, or is not correctly packaged/found when used with certain tools (like Nuitka).","error":"ModuleNotFoundError: No module named 'blis'"},{"fix":"Consult the `blis` documentation for the correct way to import and use its functions. Most high-level operations are accessed directly from the `blis` package (e.g., `import blis; blis.gemm(...)`) or from specific submodules (e.g., `from blis.ru import gemm`).","cause":"This error arises when trying to access a non-existent submodule or attribute named 'py' directly within the `blis` module. The high-level Python API functions are typically exposed directly under the `blis` module or its submodules like `blis.ru`, not through a '.py' attribute.","error":"AttributeError: module 'blis' has no attribute 'py'"},{"fix":"Perform a clean reinstallation of `blis` in a fresh virtual environment. You can try `pip install --no-cache-dir --force-reinstall blis`. If you are compiling `blis` from source or linking against a custom BLAS, ensure that the compilation process completes successfully and that `blis` is correctly configured to include the necessary CBLAS functions.","cause":"This issue suggests a problem with the `blis` Cython extension (`blis.cy`), where it fails to expose a required BLAS function (like `sgemm`), typically due to a corrupted installation, an incomplete compilation, or conflicts with other BLAS implementations on the system.","error":"ImportError: blis.cy does not export expected C function sgemm"}],"ecosystem":"pypi","meta_description":null,"install_score":90,"install_tag":"verified","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.3.3","cli_name":"","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.24,"mem_mb":6.8,"disk_size":"126.5M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":6.8,"disk_size":"126.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":3.8,"import_time_s":0.2,"mem_mb":6.8,"disk_size":"119M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.15,"mem_mb":6.8,"disk_size":"119M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.36,"mem_mb":7.2,"disk_size":"134.2M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.32,"mem_mb":7.2,"disk_size":"134.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":3.7,"import_time_s":0.32,"mem_mb":7.2,"disk_size":"126M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.27,"mem_mb":7.2,"disk_size":"126M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.31,"mem_mb":7.1,"disk_size":"122.6M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.27,"mem_mb":7.1,"disk_size":"122.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":3.7,"import_time_s":0.32,"mem_mb":7.1,"disk_size":"114M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":7.1,"disk_size":"114M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.23,"mem_mb":7.6,"disk_size":"122.1M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.25,"mem_mb":7.6,"disk_size":"122.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":3.5,"import_time_s":0.3,"mem_mb":7.6,"disk_size":"114M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":7.6,"disk_size":"114M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"build_error","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"build_error","install_time_s":11.2,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}