Skip to main content

Minimal Python library for working with bit vectors natively.

Project description

Minimal Python library for working with bit vectors natively.

PyPI version and link.

Purpose

This library allows programmers to work with a native representation of bit vectors within Python.

Package Installation and Usage

The package is available on PyPI:

python -m pip install bitlist

The library can be imported in the usual way:

import bitlist
from bitlist import bitlist

Testing

The library comes with a number of tests:

nosetests
python bitlist/bitlist.py -v

Examples

An example of usage (a bitwise addition function) is provided below:

from bitlist import bitlist
def add(x, y):
    """Bitwise addition algorithm."""
    k = len(x)
    l = len(y)
    r = bitlist(0)

    # Upper bound is not inclusive.
    # Use negative indices for big-endian interface.
    carry = 0
    for i in range(1, max(k, l) + 1):
        r[-i] = (x[-i] ^ y[-i]) ^ carry
        carry = (x[-i] & y[-i]) | (x[-i] & carry) | (y[-i] & carry)
    r[-(max(k, l) + 1)] = carry

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitlist-0.2.0.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitlist-0.2.0.4-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file bitlist-0.2.0.4.tar.gz.

File metadata

  • Download URL: bitlist-0.2.0.4.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.0

File hashes

Hashes for bitlist-0.2.0.4.tar.gz
Algorithm Hash digest
SHA256 0d9ab1ec7bc39bc1f33fbc07e9358be35dafbc56cce1ecb3988521a86a6ff232
MD5 28f6b4105c6eaa854d6c3473326db097
BLAKE2b-256 79d2d7f30ad590ba138661e974a67c150cc868c42e5e63dd428c3e403010cc2b

See more details on using hashes here.

File details

Details for the file bitlist-0.2.0.4-py3-none-any.whl.

File metadata

  • Download URL: bitlist-0.2.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.0

File hashes

Hashes for bitlist-0.2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0b553ef30b30daf0cd1f231917469e7dc55b05e5657a4bec6f55362582ca1e5a
MD5 02cd39ca3f6b39ab39346533b916f878
BLAKE2b-256 826c33b04ba221286e133c289b9924b17aab9a34f1fd5dc2fbd4613074ddb1b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page