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
dsi_bitstream-0.1.0.tar.gz
(22.0 kB
view hashes)
Built Distributions
Close
Hashes for dsi_bitstream-0.1.0-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da661a82f32cb29a0002d04b41d058769257e314a2567988cbedb5cec981ec56 |
|
MD5 | 83301499d7f164f3bed45e70794184c2 |
|
BLAKE2b-256 | 0b65b3deceec583ccc4f945dad6a52996081de55be2994c7e60f00516d31526b |
Close
Hashes for dsi_bitstream-0.1.0-cp37-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8d0cfd95b6b92d5e6642244ffb57fb4de1511a68659c77694730f686a122041 |
|
MD5 | f2d1c46779538c44f67f94844f269ef6 |
|
BLAKE2b-256 | 7e6ec7b8f0d989a72c75dd8c34ebe900447e1905df462791abbfbe15b60305f7 |
Close
Hashes for dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97aebf27fcca7e33cf441d0d6376fcd37e234b60bbfda4d26c4a605d091155e9 |
|
MD5 | b67607bcf874145a7c815d826628d9cf |
|
BLAKE2b-256 | 888de861985d7aaee225fe938ee2a355572d1401da9609f93ae867cf9cd3ebee |
Close
Hashes for dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8c30389da691d84fef54f508edaa61d567d102c862bb4ddca4e66ccdeac86e7 |
|
MD5 | bf6d185ed926fa19d3030670e84665c7 |
|
BLAKE2b-256 | 175f00a0ef517135b0446f76299ca770d5e669218c82859771d0e92d39b4e99b |
Close
Hashes for dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14b74183044082555bad05199fc9e5a975372ad5e2e6b4690b60edc0e602f578 |
|
MD5 | f728550726edb6e5af7fd59674812a89 |
|
BLAKE2b-256 | d5a4b8159ed5eac17e63eed3e9eb9a1e25e0b7dd0b8f7179df1761724124e85c |
Close
Hashes for dsi_bitstream-0.1.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8405bfa6316108bff364b8f37a1859c89a0a69cc063a1e6b48a6ce91e198b087 |
|
MD5 | 5c00b99d48e447c84fd2f8450d37b6f5 |
|
BLAKE2b-256 | 86cebfcdd211a30b3f52bba6d1be84b88b75b14e36f5680a3e05eb20dc17b485 |
Close
Hashes for dsi_bitstream-0.1.0-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a094c31e7b419224cef8c845dddcf2f939d009c9b761c5275cd74c931b1233d4 |
|
MD5 | 8378be84efab55f05ea434b01aed9eea |
|
BLAKE2b-256 | 748f200b63923af92f8daaac6a695748b061955cb9abc7e69d086e2137206f52 |