Skip to main content

binar - High-performance binary arithmetic

Fast bit vectors and bit matrices with linear algebra over GF(2).

Overview

binar provides efficient Python bindings to high-performance Rust implementations of:

  • Bit vectors (BitVector) - Variable-length sequences of bits
  • Bit matrices (BitMatrix) - 2D arrays of bits with linear algebra operations
  • Operations optimized for quantum computing and error correction

The library is designed for applications requiring fast linear algebra over GF(2) (the binary field with elements {0, 1}), where addition is XOR and multiplication is AND.

Installation

pip install binar

For development:

cd binar/bindings/python
maturin develop --release

Quick Start

import binar

# Bit vectors: create, manipulate, and compute
v1 = binar.BitVector("10110")
v2 = binar.BitVector([True, False, True, False, False])
print(v1.weight)  # 3 (number of 1s)
print(v1.support)  # [0, 2, 3] (indices of 1s)

# Boolean operations
v3 = v1 ^ v2  # XOR
print(v1.dot(v2))  # Inner product over GF(2)

# Bit matrices: linear algebra over GF(2)
m = binar.BitMatrix([
    "1010",
    "0110",
    "1100",
    "0011"
])
print(m.shape)  # (4, 4)

# Matrix operations
identity = binar.BitMatrix.identity(4)
product = m @ identity  # Matrix multiplication
m_rref = m.echelonized()  # Row echelon form
kernel = m.kernel()  # Null space basis

Key Features

BitVector

  • Create from strings, lists, or factory methods
  • Boolean operations: XOR, AND, OR
  • Hamming weight and parity computation
  • Inner product over GF(2)
  • Support (indices of set bits)

BitMatrix

  • Create from rows or factory methods
  • Matrix multiplication over GF(2)
  • Element-wise boolean operations
  • Row echelon form and reduced row echelon form
  • Null space (kernel) computation
  • Transpose and submatrix extraction

Use Cases

binar is particularly useful for:

  • Quantum error correction: Parity check matrices, stabilizer codes
  • Linear codes: Generator and check matrices over GF(2)
  • Graph theory: Adjacency matrices, graph algorithms
  • Cryptography: Linear feedback shift registers, boolean functions
  • Computational algebra: Gaussian elimination, system solving over GF(2)

Performance

Built on optimized Rust code with:

  • SIMD acceleration for bit operations
  • Cache-friendly memory layout
  • Efficient Gaussian elimination algorithms
  • Zero-copy integration between Python and Rust

Examples

Solving Linear Systems over GF(2)

import binar

# Coefficient matrix
A = binar.BitMatrix([
    "110",
    "101",
    "011"
])

# Find kernel (solutions to Ax = 0)
kernel = A.kernel()
print(f"Null space dimension: {kernel.row_count}")

# Verify solution
for row in kernel.rows:
    result = A @ row
    assert result.is_zero  # Ax = 0

Parity Check Matrix for [7,4,3] Hamming Code

import binar

# Parity check matrix for [7,4,3] Hamming code
H = binar.BitMatrix([
    "1010101",
    "0110011",
    "0001111"
])

# Check syndrome for error vector
error = binar.BitVector("0001000")  # Error on bit 3
syndrome = H @ error
print(f"Syndrome: {syndrome}")  # Points to error location

# Generate all codewords by finding kernel
codewords = H.kernel()
print(f"Code dimension: {codewords.row_count}")  # 4

API Reference

See the type stubs file for complete API documentation with type hints.

  • paulimer: Pauli and Clifford algebra built on binar

License

MIT License - See LICENSE file for details.

Contributing

Contributions welcome! See github.com/microsoft/qdk-ec for guidelines.

Metadata

Release files for binar 0.1.9

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 binar 0.1.9
File Actions
binar-0.1.9-cp315-abi3.abi3t-win_arm64.whl CPython 3.15 abi3t, abi3 Windows ARM64 Details for binar-0.1.9-cp315-abi3.abi3t-win_arm64.whl
binar-0.1.9-cp315-abi3.abi3t-win_amd64.whl CPython 3.15 abi3t, abi3 Windows x86-64 Details for binar-0.1.9-cp315-abi3.abi3t-win_amd64.whl
binar-0.1.9-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl CPython 3.15 abi3t, abi3 Linux glibc 2.28+ x86-64 Details for binar-0.1.9-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl
binar-0.1.9-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl CPython 3.15 abi3t, abi3 Linux glibc 2.28+ ARM64 Details for binar-0.1.9-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl
binar-0.1.9-cp315-abi3.abi3t-macosx_11_0_arm64.whl CPython 3.15 abi3, abi3t macOS 11.0+ ARM64 Details for binar-0.1.9-cp315-abi3.abi3t-macosx_11_0_arm64.whl
binar-0.1.9-cp315-abi3.abi3t-macosx_10_12_x86_64.whl CPython 3.15 abi3t, abi3 macOS 10.12+ x86-64 Details for binar-0.1.9-cp315-abi3.abi3t-macosx_10_12_x86_64.whl
binar-0.1.9-cp314-cp314t-win_arm64.whl CPython 3.14 CPython 3.14 free-threading Windows ARM64 Details for binar-0.1.9-cp314-cp314t-win_arm64.whl
binar-0.1.9-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for binar-0.1.9-cp314-cp314t-win_amd64.whl
binar-0.1.9-cp314-cp314t-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 Details for binar-0.1.9-cp314-cp314t-manylinux_2_28_x86_64.whl
binar-0.1.9-cp314-cp314t-manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64 Details for binar-0.1.9-cp314-cp314t-manylinux_2_28_aarch64.whl
binar-0.1.9-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for binar-0.1.9-cp314-cp314t-macosx_11_0_arm64.whl
binar-0.1.9-cp314-cp314t-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 Details for binar-0.1.9-cp314-cp314t-macosx_10_12_x86_64.whl
binar-0.1.9-cp314-cp314-pyemscripten_2026_0_wasm32.whl CPython 3.14 CPython 3.14 PyEmscripten 2026.0+ WebAssembly Details for binar-0.1.9-cp314-cp314-pyemscripten_2026_0_wasm32.whl
binar-0.1.9-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for binar-0.1.9-cp39-abi3-win_arm64.whl
binar-0.1.9-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for binar-0.1.9-cp39-abi3-win_amd64.whl
binar-0.1.9-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for binar-0.1.9-cp39-abi3-manylinux_2_28_x86_64.whl
binar-0.1.9-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for binar-0.1.9-cp39-abi3-manylinux_2_28_aarch64.whl
binar-0.1.9-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for binar-0.1.9-cp39-abi3-macosx_11_0_arm64.whl
binar-0.1.9-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for binar-0.1.9-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 6.7 MB

Release files / binar-0.1.9-cp315-abi3.abi3t-win_arm64.whl

Download URL binar-0.1.9-cp315-abi3.abi3t-win_arm64.whl
Size 267.7 kB
Tags CPython 3.15 Windows ARM64 abi3 abi3t
SHA-256 checksum
How to use checksums
ede3bed1a9a12369a2af51f7d8177fe081b9006e859f9a2b3df9675c15547c54
BLAKE2b-256 checksum
How to use checksums
bb228e2724cfbb5b7a09bf896fc90ce44b54dc4aaee890ebbd064d1ff41db36d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp315-abi3.abi3t-win_amd64.whl

Download URL binar-0.1.9-cp315-abi3.abi3t-win_amd64.whl
Size 296.2 kB
Tags CPython 3.15 Windows x86-64 abi3 abi3t
SHA-256 checksum
How to use checksums
01a715a8693aa6d38293d95beb0250f5a0ad4d6630be96f81dfdeff218b8a9de
BLAKE2b-256 checksum
How to use checksums
9e0026bedcbab36d0c3d99983eab9230d9ff5db50cd4767c6868af79d3486c5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl

Download URL binar-0.1.9-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl
Size 356.1 kB
Tags CPython 3.15 Linux glibc 2.28+ x86-64 abi3 abi3t
SHA-256 checksum
How to use checksums
89299691fd4c4253b8b6e48800ea039b097e5b437181beb897842f0bdea17359
BLAKE2b-256 checksum
How to use checksums
d72c004d8d73f3e8c9892b32daced7ebc669a9a0f719023a01d6132ff30bf40d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl

Download URL binar-0.1.9-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl
Size 332.6 kB
Tags CPython 3.15 Linux glibc 2.28+ ARM64 abi3 abi3t
SHA-256 checksum
How to use checksums
e02ff458562407f35ef79a12fd3d5f1cfc49ecf09cd4133410576089ff539649
BLAKE2b-256 checksum
How to use checksums
cbb7e3d623fa42d4f69ecd41e2fd2471de2d15e5765bb625e744ebb4af1ae9e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp315-abi3.abi3t-macosx_11_0_arm64.whl

Download URL binar-0.1.9-cp315-abi3.abi3t-macosx_11_0_arm64.whl
Size 298.9 kB
Tags CPython 3.15 abi3 abi3t macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5726b00b0f91af4cded4f331fdd0f440caa40c7de948cb2f3c3de197b1408475
BLAKE2b-256 checksum
How to use checksums
77291fe0098dda0c43527c037895c49d3ff34b7e67dd8b7edc511e1c5f9c7da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp315-abi3.abi3t-macosx_10_12_x86_64.whl

Download URL binar-0.1.9-cp315-abi3.abi3t-macosx_10_12_x86_64.whl
Size 316.2 kB
Tags CPython 3.15 abi3 abi3t macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
79c6f98c4b0523b337486ba547559222cb953aa81d926de6d55e82abd3d7fb00
BLAKE2b-256 checksum
How to use checksums
f105365eab02837b7ff9222c84b5c9b5fa629d88a70e7edf0a73558b79b48228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp314-cp314t-win_arm64.whl

Download URL binar-0.1.9-cp314-cp314t-win_arm64.whl
Size 270.3 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows ARM64
SHA-256 checksum
How to use checksums
ed2b56c36b209b8a7abad46c29895e301be07381223e19c41187ee4e40828840
BLAKE2b-256 checksum
How to use checksums
c8a42b34521d3ead76ca771de7451818b290bb9f9ca87aab84984882f22e6f42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp314-cp314t-win_amd64.whl

Download URL binar-0.1.9-cp314-cp314t-win_amd64.whl
Size 279.7 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
77cb541c1899de51b9dbf0928cc812354509d675ca9187e74dfc5151a707e318
BLAKE2b-256 checksum
How to use checksums
1512b442f694b8c2f4d50e63cc0996f0569890eae7ad99784ed0e21654533fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp314-cp314t-manylinux_2_28_x86_64.whl

Download URL binar-0.1.9-cp314-cp314t-manylinux_2_28_x86_64.whl
Size 338.8 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
dbde649547834f337931d7509d61806f51d22c6d063ef0a2fb1b896f45ffe04c
BLAKE2b-256 checksum
How to use checksums
007e50955e026b164ef043a273f837f92b11a8203aee6f85875bfc88e392414b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp314-cp314t-manylinux_2_28_aarch64.whl

Download URL binar-0.1.9-cp314-cp314t-manylinux_2_28_aarch64.whl
Size 319.2 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
5c5eb4001810caf486517fb5a62efb6b46f8a03fe1b1fdf1388469c40d3f3f61
BLAKE2b-256 checksum
How to use checksums
96da6bdfff5913173f2d25f45bb4eb1cb30d9f8832ec1f392cf349f4c99dc0ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp314-cp314t-macosx_11_0_arm64.whl

Download URL binar-0.1.9-cp314-cp314t-macosx_11_0_arm64.whl
Size 285.9 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ce96379eca825eab759ea10a1449ea963f4ba09179c7de06da0afdf8bbb22e5e
BLAKE2b-256 checksum
How to use checksums
c4d0cec325b0ef612e257eb245e73402585d3712f9cdc384f91128cf4b6e4487
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp314-cp314t-macosx_10_12_x86_64.whl

Download URL binar-0.1.9-cp314-cp314t-macosx_10_12_x86_64.whl
Size 301.2 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d57904d40f2563dc2854ef4bc215c83ebea43af8f84f290c758ef04569ad4f80
BLAKE2b-256 checksum
How to use checksums
47a0ed91ab640f63b803d9e1f1259abbe699fd93afdab369a0b4cd8315f32849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp314-cp314-pyemscripten_2026_0_wasm32.whl

Download URL binar-0.1.9-cp314-cp314-pyemscripten_2026_0_wasm32.whl
Size 1.2 MB
Tags CPython 3.14 PyEmscripten 2026.0+ WebAssembly
SHA-256 checksum
How to use checksums
91f34609703610a96a10afac028d00a59c0308c3f0b3a2c35051bb0294d4630b
BLAKE2b-256 checksum
How to use checksums
23f18cdcc4fe2cbd252523f9febf560613bad40d57e31dee3f4e3284a4c09f5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp39-abi3-win_arm64.whl

Download URL binar-0.1.9-cp39-abi3-win_arm64.whl
Size 273.5 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
8cbd7e50d6d9313500b656cbbae6d65297a633853bf5f1b18e86cd121e08f3c3
BLAKE2b-256 checksum
How to use checksums
1f8a21295cfe9213e522c9764843f81869b103da6ab5cd6c49d0b8292416eaa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp39-abi3-win_amd64.whl

Download URL binar-0.1.9-cp39-abi3-win_amd64.whl
Size 281.8 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
edf66a557225d571f1f2a72196e63313be9ea46e8a5037dcb3ee96f57262673f
BLAKE2b-256 checksum
How to use checksums
8c82b1d46f5864ee674f20c16609395ec903418d3786b4af14f1d28dd1e64f38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL binar-0.1.9-cp39-abi3-manylinux_2_28_x86_64.whl
Size 344.2 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
6f3d86f7d4634c3ac36bbc75ac1478d943f8c22f301f00c049d1781001d9ea36
BLAKE2b-256 checksum
How to use checksums
b031de34ae59a24dd8a7b1219c246907e5abdc6b5170c1382cca9374c0f346b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL binar-0.1.9-cp39-abi3-manylinux_2_28_aarch64.whl
Size 326.1 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
3df68806cc1d9d4989be6b5d1e53fa6dfcc335cccb80c6d5120f674107e15b51
BLAKE2b-256 checksum
How to use checksums
71135f711668731f7373b7dd92d20f914a2283f80f05e5f32c0ea9f8512a95bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp39-abi3-macosx_11_0_arm64.whl

Download URL binar-0.1.9-cp39-abi3-macosx_11_0_arm64.whl
Size 296.7 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8e4612cbf9b87cc07fa7c4fd71dfc67615398da533eececa3683b0d7c30b6d66
BLAKE2b-256 checksum
How to use checksums
7d89e679e82e0012b32ad426dbbb12244d6aaa0ff083acf76520da60aafddd5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / binar-0.1.9-cp39-abi3-macosx_10_12_x86_64.whl

Download URL binar-0.1.9-cp39-abi3-macosx_10_12_x86_64.whl
Size 311.3 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
956fcc1972a0a6faf2f6e31e0c46fb4c131ceb322eb553bfe0472764b20acbe6
BLAKE2b-256 checksum
How to use checksums
99e78ba1edade64a6754ff1cd706e20a7708ea9da35ce0106fbf192b08f47a4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Security for binar 0.1.9

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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