skillfed

bitarray-hardbyte

efficient arrays of booleans -- C extension

bitarray-hardbyte v2.3.8 93.8K downloads/30d#13,363 on PyPI792
Permissive license PSF Active released

What it is and what it does

bitarray-hardbyte is a C extension that provides a memory-efficient array type for storing boolean values. Eight bits are packed into a single byte, making it far more compact than a Python list of booleans. The library supports both big-endian and little-endian bit ordering, allowing fine-grained control over how bits map to bytes—important when working with binary protocols, file formats, or memory-mapped data.

The package behaves like a standard Python sequence: you can slice, extend, iterate, and apply bitwise operations (&, |, ^, ~, <<, >>) directly on bitarray objects. It includes utility functions for encoding/decoding variable-length prefix codes, converting to hexadecimal, creating Huffman codes, and serialization. All functionality is implemented in C for speed, and the library supports the buffer protocol for zero-copy interoperability with other binary data structures like numpy arrays.

Use it for:

  • Storing large sets of boolean flags or bit masks where memory efficiency is critical.
  • Implementing Bloom filters, bitmaps, or other bit-level data structures.
  • Working with binary file formats or network protocols that require precise bit-level manipulation.
  • Creating Huffman codes or other variable-length prefix codes for compression.
  • Interfacing with memory-mapped files or C libraries that expect raw bit-level data.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides an efficient C-backed array type for storing and manipulating sequences of boolean values, with support for bitwise operations, slicing, and endianness control.

Yes, if you need memory-efficient boolean storage or bit-level operations. The package is mature, actively maintained, permissively licensed, and has no known vulnerabilities. Install friction is moderate due to C compilation, but precompiled wheels cover most common platforms. Not necessary for typical Python applications that don't require bit-level manipulation or extreme memory optimization.

Install

bitarray-hardbyte on PyPI

pip

pip install bitarray-hardbyte

uv

uv add bitarray-hardbyte

poetry

poetry add bitarray-hardbyte

Installing bitarray-hardbyte

Before you install

Medium install friction due to C compilation requirement, but precompiled wheels are available for common platforms (macOS, Linux, Windows, multiple architectures). Maintenance is active with recent commits and a stable release history since 2019.

License in practice

Licensed under the Python Software Foundation License (PSF), a permissive license that allows commercial and private use with minimal restrictions.

Quickstart

pip install bitarray-hardbyte

from bitarray import bitarray
a = bitarray()
a.append(1)
a.extend([1, 0])
print(a)  # bitarray('110')
print(a.count(1))  # 2

Requires a C compiler if installing from source; precompiled wheels available for Python 3.6–3.10 on macOS, Linux (x86_64, i686), and Windows.

Verify before relying

  • Whether bitarray-hardbyte is a maintained fork or variant of the original bitarray package and how it differs functionally.
  • Current Python 3.11+ support status, given that friction evidence shows wheels only up to cp310.

Package facts

License PSF (permissive)
Python support not specified
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 1,628 days since the last release
Last repo commit
First released
Downloads 93,774/month — #13,363 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: bitarray_hardbyte-2.3.8-cp310-cp310-macosx_10_9_x86_64.whl; bitarray_hardbyte-2.3.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; bitarray_hardbyte-2.3.8-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; bitarray_hardbyte-2.3.8-cp310-cp310-musllinux_1_1_i686.whl; bitarray_hardbyte-2.3.8-cp310-cp310-musllinux_1_1_x86_64.whl; bitarray_hardbyte-2.3.8-cp310-cp310-win32.whl; bitarray_hardbyte-2.3.8-cp310-cp310-win_amd64.whl; bitarray_hardbyte-2.3.8-cp36-cp36m-macosx_10_9_x86_64.whl; bitarray_hardbyte-2.3.8-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; bitarray_hardbyte-2.3.8-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; bitarray_hardbyte-2.3.8-cp36-cp36m-musllinux_1_1_i686.whl; bitarray_hardbyte-2.3.8-cp36-cp36m-musllinux_1_1_x86_64.whl; bitarray_hardbyte-2.3.8-cp36-cp36m-win32.whl; bitarray_hardbyte-2.3.8-cp36-cp36m-win_amd64.whl; bitarray_hardbyte-2.3.8-cp37-cp37m-macosx_10_9_x86_64.whl; bitarray_hardbyte-2.3.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; bitarray_hardbyte-2.3.8-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; bitarray_hardbyte-2.3.8-cp37-cp37m-musllinux_1_1_i686.whl; bitarray_hardbyte-2.3.8-cp37-cp37m-musllinux_1_1_x86_64.whl; bitarray_hardbyte-2.3.8-cp37-cp37m-win32.whl

Development Status :: 6 - MatureIntended Audience :: DevelopersLicense :: OSI Approved :: Python Software Foundation LicenseOperating System :: OS IndependentProgramming Language :: CProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Utilities

Tags

boolean array librarybit manipulation in pythonefficient bitarray implementationbitwise operations librarymemory-efficient boolean storage
bit-manipulationc-extensionmemory-efficient

More Utilities packages