Minimal Python library for working with little-endian list representation of bit strings.
Project description
Minimal pure Python library for working with little-endian list representation of bit strings.
Purpose
This library allows programmers to work with a little-endian representation of bit strings within Python. Its purpose is primarily pedagogical, although it can be useful under other circumstances.
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
Examples
An example of usage (a bitwise addition function) is provided below:
from bitlist import bitlist def add(x, y): k = len(x) l = len(y) r = bitlist(0) c = 0 for i in range(0, max(k,l)): # Upper bound is not inclusive. r[i] = (x[i] ^ y[i]) ^ c c = (x[i] & y[i]) | (x[i] & c) | (y[i] & c) r[max(k,l)] = c return r
Project details
Release history Release notifications | RSS feed
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.1.0.2.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for bitlist-0.1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | edecd630fc0c83343696af387332478ff9729da4bde1452b048200753e63c513 |
|
MD5 | 3d356a4a2df907eaaa63ee66bef42491 |
|
BLAKE2b-256 | 8bf09ed236b0af495d5f05b81d80f34d34661fd78edf421358233067405ad1e4 |