Skip to main content

Binsparse Python Reference Implementation

This library is a reference implementation of the Binsparse Binary Sparse Format Specification written using Python.

Binsparse is a cross-platform, embeddable format for storing sparse matrices and tensors. This library implements Binsparse bindings for NumPy NPZ, HDF5, and Zarr containers, with conversion interfaces for NumPy, SciPy, PyTorch, and PyData/Sparse.

Python Binsparse Interface

The primary interface consists of load_binsparse and save_binsparse. These functions select a container from the path extension (.npz, .h5/.hdf5, or .zarr) and read or write a BinsparseTensor:

from binsparse import load_binsparse, save_binsparse

tensor = load_binsparse("input.h5")
save_binsparse(tensor, "output.npz")

Parsed tensors expose their logical shape, number_of_stored_values, optional fill value, and the arrays that define their storage format. Concrete tensor classes represent the predefined Binsparse formats, including dense vectors and matrices, compressed sparse rows and columns, doubly compressed matrices, and coordinate formats. CustomTensor and the level classes (DenseLevel, SparseLevel, and ElementLevel) represent arbitrary level-based format descriptors.

For applications that already manage their own storage objects, the lower-level BinsparseContainer interface separates tensor parsing and serialization from the physical container. Adapters are provided for NPZ mappings, HDF5 files, Zarr groups, and in-memory descriptors and buffers. Use BinsparseTensor.parse(container) to read through an adapter and tensor.serialize(container) to write through one.

The alias option controls whether predefined format names such as CSR are preserved or expanded to custom level descriptors. The copy option allows a caller to request a copy, permit whichever representation is required, or require a zero-copy operation when the source and destination support it.

binsparse.conversions exports the following conversion functions:

  • NumPy: from_numpy and to_numpy
  • SciPy: from_scipy and to_scipy
  • PyTorch: from_torch and to_torch
  • PyData/Sparse: from_sparse and to_sparse

NumPy support is included by default; the other adapters require their corresponding optional dependency.

Source

The source code for binsparse is available on GitHub at https://github.com/Binsparse/binsparse-reference-python

Installation

binsparse is available on PyPi, and can be installed with pip:

pip install binsparse

Metadata

Release files for binsparse 0.1.3

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

Source distribution (sdist)

Source distribution for binsparse 0.1.3
File Size Uploaded
binsparse-0.1.3.tar.gz 70.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for binsparse 0.1.3
File Interpreter ABI Platform
binsparse-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 93.4 kB

Release files / binsparse-0.1.3.tar.gz

Download URL binsparse-0.1.3.tar.gz
Size 70.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3974a96675e989564dbae93f19b1580ae6044db23abb56a5b87e8fa2788c05e1
BLAKE2b-256 checksum
How to use checksums
46f83289c896e88c1285eb322d17605154ab26181b3d68dad1bb77e35d0096a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / binsparse-0.1.3-py3-none-any.whl

Download URL binsparse-0.1.3-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12392e76ac7394b0acdfa8c9863d926a73210a392d4da57f1bbcec44016ee789
BLAKE2b-256 checksum
How to use checksums
674bb70d78e314322a0a928ceadc2f7ec490a150c14ce439edc2fd3276fba7bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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