dsi-bitstream


Namedsi-bitstream JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryPython bindings for the Rust implementation of read/write bit streams supporting several types of instantaneous codes
upload_time2024-05-25 10:37:53
maintainerNone
docs_urlNone
authorTommaso Fontana, Sebastiano Vigna
requires_python>=3.7
licenseApache-2.0 OR LGPL-2.1-or-later
keywords bitstream codes compression
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dsi-bitstream-py
![GitHub CI](https://github.com/zommiommy/dsi-bitstream-py/actions/workflows/rust.yml/badge.svg)
![license](https://img.shields.io/crates/l/dsi-bitstream)
[![](https://tokei.rs/b1/github/zommiommy/dsi-bitstream-py?type=Rust,Python)](https://github.com/zommiommy/dsi-bitstream-py)
[![Supported Python versions](https://img.shields.io/badge/Python-3.7+-blue.svg)](https://pypi.org/project/ensmallen/#history)
[![Pypi total project downloads](https://pepy.tech/badge/dsi_bitstream)](https://pepy.tech/badge/dsi_bitstream)
[![Pypi project](https://badge.fury.io/py/dsi_bitstream.svg)](https://badge.fury.io/py/dsi_bitstream)

Python bindings of dsi-bitstream-rs

Install with:
```
pip install dsi_bitstream
```

Example:
```python
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:
```shell
docker run --rm -v $PWD:/io ghcr.io/pyo3/maturin build --release
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dsi-bitstream",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Tommaso Fontana <tommaso.fontana.96@gmail.com>",
    "keywords": "bitstream, codes, compression",
    "author": "Tommaso Fontana, Sebastiano Vigna",
    "author_email": "tommaso.fontana.96@gmail.com, sebastiano.vigna@unimi.it",
    "download_url": "https://files.pythonhosted.org/packages/7b/aa/a4bfb2a685e8b3635bd09684461ca0f2342d121761322589b8b66e0b9a01/dsi_bitstream-0.1.0.tar.gz",
    "platform": null,
    "description": "# dsi-bitstream-py\n![GitHub CI](https://github.com/zommiommy/dsi-bitstream-py/actions/workflows/rust.yml/badge.svg)\n![license](https://img.shields.io/crates/l/dsi-bitstream)\n[![](https://tokei.rs/b1/github/zommiommy/dsi-bitstream-py?type=Rust,Python)](https://github.com/zommiommy/dsi-bitstream-py)\n[![Supported Python versions](https://img.shields.io/badge/Python-3.7+-blue.svg)](https://pypi.org/project/ensmallen/#history)\n[![Pypi total project downloads](https://pepy.tech/badge/dsi_bitstream)](https://pepy.tech/badge/dsi_bitstream)\n[![Pypi project](https://badge.fury.io/py/dsi_bitstream.svg)](https://badge.fury.io/py/dsi_bitstream)\n\nPython bindings of dsi-bitstream-rs\n\nInstall with:\n```\npip install dsi_bitstream\n```\n\nExample:\n```python\nfrom dsi_bitstream import BitReaderLittleEndian, BitWriterLittleEndian\n\nwriter = BitWriterLittleEndian(\"./bitstream.bin\")\n\n# all write methods return how many bits were written\nwriter.write_bits(10, n = 5) # write 10 as 5 bits \nwriter.write_unary(100)\nwriter.write_gamma(10)\nwriter.write_delta(2)\nwriter.write_rice(3, k=4)\nwriter.write_golomb(4, k=10)\nwriter.write_zeta(10, k=3)\nwriter.write_exp_golomb(100, k=3)\nwriter.write_minimal_binary(10, max=100)\nwriter.flush()\n\nreader = BitReaderLittleEndian(\"./bitstream.bin\")\nassert reader.read_bits(n = 5) == 10\nassert reader.read_unary() == 100\nassert reader.read_gamma() == 10\nprint(reader.bit_pos()) # bits from the start of the file (here 497)\nassert reader.read_delta() == 2\nassert reader.read_rice(k=4) == 3\nassert reader.read_golomb(k=10) == 4\nassert reader.read_zeta(k=3) == 10\nassert reader.read_exp_golomb(k=3) == 100\nassert reader.read_minimal_binary(max=100) == 10\n\n# the reader can seek in the file, while the writer cannot.\nreader.set_bit_pos(497)\nassert reader.read_delta() == 2\nassert reader.read_rice(k=4) == 3\nassert reader.read_golomb(k=10) == 4\nassert reader.read_zeta(k=3) == 10\nassert reader.read_exp_golomb(k=3) == 100\nassert reader.read_minimal_binary(max=100) == 10\n```\n\n\n## Building\nTo publish on pypi for linux:\n```shell\ndocker run --rm -v $PWD:/io ghcr.io/pyo3/maturin build --release\n```\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0 OR LGPL-2.1-or-later",
    "summary": "Python bindings for the Rust implementation of read/write bit streams supporting several types of instantaneous codes",
    "version": "0.1.0",
    "project_urls": {
        "changelog": "http://github.com/zommiommy/dsi-bitstream-py/blob/master/CHANGELOG.md",
        "repository": "http://github.com/zommiommy/dsi-bitstream-py"
    },
    "split_keywords": [
        "bitstream",
        " codes",
        " compression"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "748f200b63923af92f8daaac6a695748b061955cb9abc7e69d086e2137206f52",
                "md5": "8378be84efab55f05ea434b01aed9eea",
                "sha256": "a094c31e7b419224cef8c845dddcf2f939d009c9b761c5275cd74c931b1233d4"
            },
            "downloads": -1,
            "filename": "dsi_bitstream-0.1.0-cp37-abi3-macosx_10_12_x86_64.whl",
            "has_sig": false,
            "md5_digest": "8378be84efab55f05ea434b01aed9eea",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 279859,
            "upload_time": "2024-05-25T10:37:51",
            "upload_time_iso_8601": "2024-05-25T10:37:51.344867Z",
            "url": "https://files.pythonhosted.org/packages/74/8f/200b63923af92f8daaac6a695748b061955cb9abc7e69d086e2137206f52/dsi_bitstream-0.1.0-cp37-abi3-macosx_10_12_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "86cebfcdd211a30b3f52bba6d1be84b88b75b14e36f5680a3e05eb20dc17b485",
                "md5": "5c00b99d48e447c84fd2f8450d37b6f5",
                "sha256": "8405bfa6316108bff364b8f37a1859c89a0a69cc063a1e6b48a6ce91e198b087"
            },
            "downloads": -1,
            "filename": "dsi_bitstream-0.1.0-cp37-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "5c00b99d48e447c84fd2f8450d37b6f5",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 275275,
            "upload_time": "2024-05-25T10:37:49",
            "upload_time_iso_8601": "2024-05-25T10:37:49.279247Z",
            "url": "https://files.pythonhosted.org/packages/86/ce/bfcdd211a30b3f52bba6d1be84b88b75b14e36f5680a3e05eb20dc17b485/dsi_bitstream-0.1.0-cp37-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d5a4b8159ed5eac17e63eed3e9eb9a1e25e0b7dd0b8f7179df1761724124e85c",
                "md5": "f728550726edb6e5af7fd59674812a89",
                "sha256": "14b74183044082555bad05199fc9e5a975372ad5e2e6b4690b60edc0e602f578"
            },
            "downloads": -1,
            "filename": "dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_aarch64.whl",
            "has_sig": false,
            "md5_digest": "f728550726edb6e5af7fd59674812a89",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 1223309,
            "upload_time": "2024-05-25T10:37:41",
            "upload_time_iso_8601": "2024-05-25T10:37:41.556869Z",
            "url": "https://files.pythonhosted.org/packages/d5/a4/b8159ed5eac17e63eed3e9eb9a1e25e0b7dd0b8f7179df1761724124e85c/dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "175f00a0ef517135b0446f76299ca770d5e669218c82859771d0e92d39b4e99b",
                "md5": "bf6d185ed926fa19d3030670e84665c7",
                "sha256": "f8c30389da691d84fef54f508edaa61d567d102c862bb4ddca4e66ccdeac86e7"
            },
            "downloads": -1,
            "filename": "dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_i686.whl",
            "has_sig": false,
            "md5_digest": "bf6d185ed926fa19d3030670e84665c7",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 1246522,
            "upload_time": "2024-05-25T10:37:44",
            "upload_time_iso_8601": "2024-05-25T10:37:44.415624Z",
            "url": "https://files.pythonhosted.org/packages/17/5f/00a0ef517135b0446f76299ca770d5e669218c82859771d0e92d39b4e99b/dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_i686.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "888de861985d7aaee225fe938ee2a355572d1401da9609f93ae867cf9cd3ebee",
                "md5": "b67607bcf874145a7c815d826628d9cf",
                "sha256": "97aebf27fcca7e33cf441d0d6376fcd37e234b60bbfda4d26c4a605d091155e9"
            },
            "downloads": -1,
            "filename": "dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "b67607bcf874145a7c815d826628d9cf",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 1223219,
            "upload_time": "2024-05-25T10:37:46",
            "upload_time_iso_8601": "2024-05-25T10:37:46.913959Z",
            "url": "https://files.pythonhosted.org/packages/88/8d/e861985d7aaee225fe938ee2a355572d1401da9609f93ae867cf9cd3ebee/dsi_bitstream-0.1.0-cp37-abi3-musllinux_1_1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7e6ec7b8f0d989a72c75dd8c34ebe900447e1905df462791abbfbe15b60305f7",
                "md5": "f2d1c46779538c44f67f94844f269ef6",
                "sha256": "a8d0cfd95b6b92d5e6642244ffb57fb4de1511a68659c77694730f686a122041"
            },
            "downloads": -1,
            "filename": "dsi_bitstream-0.1.0-cp37-abi3-win32.whl",
            "has_sig": false,
            "md5_digest": "f2d1c46779538c44f67f94844f269ef6",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 169920,
            "upload_time": "2024-05-25T10:37:56",
            "upload_time_iso_8601": "2024-05-25T10:37:56.882632Z",
            "url": "https://files.pythonhosted.org/packages/7e/6e/c7b8f0d989a72c75dd8c34ebe900447e1905df462791abbfbe15b60305f7/dsi_bitstream-0.1.0-cp37-abi3-win32.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0b65b3deceec583ccc4f945dad6a52996081de55be2994c7e60f00516d31526b",
                "md5": "83301499d7f164f3bed45e70794184c2",
                "sha256": "da661a82f32cb29a0002d04b41d058769257e314a2567988cbedb5cec981ec56"
            },
            "downloads": -1,
            "filename": "dsi_bitstream-0.1.0-cp37-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "83301499d7f164f3bed45e70794184c2",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": ">=3.7",
            "size": 169364,
            "upload_time": "2024-05-25T10:37:54",
            "upload_time_iso_8601": "2024-05-25T10:37:54.961522Z",
            "url": "https://files.pythonhosted.org/packages/0b/65/b3deceec583ccc4f945dad6a52996081de55be2994c7e60f00516d31526b/dsi_bitstream-0.1.0-cp37-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7baaa4bfb2a685e8b3635bd09684461ca0f2342d121761322589b8b66e0b9a01",
                "md5": "42f74f1d9d290bf4361e42f28c591a26",
                "sha256": "98ed9439fd3f6647311217c9c2c8307816c055413e49d0ef00910d674c9c385f"
            },
            "downloads": -1,
            "filename": "dsi_bitstream-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "42f74f1d9d290bf4361e42f28c591a26",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 21972,
            "upload_time": "2024-05-25T10:37:53",
            "upload_time_iso_8601": "2024-05-25T10:37:53.296972Z",
            "url": "https://files.pythonhosted.org/packages/7b/aa/a4bfb2a685e8b3635bd09684461ca0f2342d121761322589b8b66e0b9a01/dsi_bitstream-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-25 10:37:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zommiommy",
    "github_project": "dsi-bitstream-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dsi-bitstream"
}
        
Elapsed time: 0.56319s