Python bindings for the Rust implementation of read/write bit streams supporting several types of instantaneous codes
Project description
dsi-bitstream-py
Python bindings of dsi-bitstream-rs
Install with:
pip install dsi_bitstream
Example:
from dsi_bitstream import BitReaderLittleEndian, BitWriterLittleEndian
writer = BitWriterLittleEndian("./bitstream.bin")
# all write methods return how many bits were written
writer.write_bits(10, n = 5) # write 10 as 5 bits
writer.write_unary(100)
writer.write_gamma(10)
writer.write_delta(2)
writer.write_rice(3, k=4)
writer.write_golomb(4, k=10)
writer.write_zeta(10, k=3)
writer.write_exp_golomb(100, k=3)
writer.write_minimal_binary(10, max=100)
writer.flush()
reader = BitReaderLittleEndian("./bitstream.bin")
assert reader.read_bits(n = 5) == 10
assert reader.read_unary() == 100
assert reader.read_gamma() == 10
print(reader.bit_pos()) # bits from the start of the file (here 497)
assert reader.read_delta() == 2
assert reader.read_rice(k=4) == 3
assert reader.read_golomb(k=10) == 4
assert reader.read_zeta(k=3) == 10
assert reader.read_exp_golomb(k=3) == 100
assert reader.read_minimal_binary(max=100) == 10
# the reader can seek in the file, while the writer cannot.
reader.set_bit_pos(497)
assert reader.read_delta() == 2
assert reader.read_rice(k=4) == 3
assert reader.read_golomb(k=10) == 4
assert reader.read_zeta(k=3) == 10
assert reader.read_exp_golomb(k=3) == 100
assert reader.read_minimal_binary(max=100) == 10
Building
To publish on pypi for linux:
docker run --rm -v $PWD:/io ghcr.io/pyo3/maturin build --release
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
Built Distributions
File details
Details for the file dsi_bitstream-0.1.0.tar.gz
.
File metadata
- Download URL: dsi_bitstream-0.1.0.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98ed9439fd3f6647311217c9c2c8307816c055413e49d0ef00910d674c9c385f |
|
MD5 | 42f74f1d9d290bf4361e42f28c591a26 |
|
BLAKE2b-256 | 7baaa4bfb2a685e8b3635bd09684461ca0f2342d121761322589b8b66e0b9a01 |
File details
Details for the file dsi_bitstream-0.1.0-cp37-abi3-win_amd64.whl
.
File metadata
- Download URL: dsi_bitstream-0.1.0-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 169.4 kB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da661a82f32cb29a0002d04b41d058769257e314a2567988cbedb5cec981ec56 |
|
MD5 | 83301499d7f164f3bed45e70794184c2 |
|
BLAKE2b-256 | 0b65b3deceec583ccc4f945dad6a52996081de55be2994c7e60f00516d31526b |
File details
Details for the file dsi_bitstream-0.1.0-cp37-abi3-win32.whl
.
File metadata
- Download URL: dsi_bitstream-0.1.0-cp37-abi3-win32.whl
- Upload date:
- Size: 169.9 kB
- Tags: CPython 3.7+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8d0cfd95b6b92d5e6642244ffb57fb4de1511a68659c77694730f686a122041 |
|
MD5 | f2d1c46779538c44f67f94844f269ef6 |
|
BLAKE2b-256 | 7e6ec7b8f0d989a72c75dd8c34ebe900447e1905df462791abbfbe15b60305f7 |
File details
Details for the file dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.7+, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97aebf27fcca7e33cf441d0d6376fcd37e234b60bbfda4d26c4a605d091155e9 |
|
MD5 | b67607bcf874145a7c815d826628d9cf |
|
BLAKE2b-256 | 888de861985d7aaee225fe938ee2a355572d1401da9609f93ae867cf9cd3ebee |
File details
Details for the file dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_i686.whl
.
File metadata
- Download URL: dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_i686.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.7+, musllinux: musl 1.1+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8c30389da691d84fef54f508edaa61d567d102c862bb4ddca4e66ccdeac86e7 |
|
MD5 | bf6d185ed926fa19d3030670e84665c7 |
|
BLAKE2b-256 | 175f00a0ef517135b0446f76299ca770d5e669218c82859771d0e92d39b4e99b |
File details
Details for the file dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_aarch64.whl
.
File metadata
- Download URL: dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_aarch64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.7+, musllinux: musl 1.1+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14b74183044082555bad05199fc9e5a975372ad5e2e6b4690b60edc0e602f578 |
|
MD5 | f728550726edb6e5af7fd59674812a89 |
|
BLAKE2b-256 | d5a4b8159ed5eac17e63eed3e9eb9a1e25e0b7dd0b8f7179df1761724124e85c |
File details
Details for the file dsi_bitstream-0.1.0-cp37-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: dsi_bitstream-0.1.0-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 275.3 kB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8405bfa6316108bff364b8f37a1859c89a0a69cc063a1e6b48a6ce91e198b087 |
|
MD5 | 5c00b99d48e447c84fd2f8450d37b6f5 |
|
BLAKE2b-256 | 86cebfcdd211a30b3f52bba6d1be84b88b75b14e36f5680a3e05eb20dc17b485 |
File details
Details for the file dsi_bitstream-0.1.0-cp37-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: dsi_bitstream-0.1.0-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 279.9 kB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a094c31e7b419224cef8c845dddcf2f939d009c9b761c5275cd74c931b1233d4 |
|
MD5 | 8378be84efab55f05ea434b01aed9eea |
|
BLAKE2b-256 | 748f200b63923af92f8daaac6a695748b061955cb9abc7e69d086e2137206f52 |