pyvint


Namepyvint JSON
Version 1.1.2 PyPI version JSON
download
home_pageNone
SummaryA Python library for pure Python encoding and decoding of integers using Variable-Size Integer (VINT).
upload_time2024-07-04 14:10:51
maintainerNone
docs_urlNone
authorosoken
requires_python>=3.8
licenseNone
keywords vint variable-size integer integer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyvint

A pure Python library for encoding and decoding Variable-Sized Integer (VINT) values.
VINT is used in EBML (Extensible Binary Meta Language) to encode integers with a variable number of bytes.
Detailed information about VINT can be found in the [Extensible Binary Meta Language RFC 8794](https://datatracker.ietf.org/doc/rfc8794/)

## Installation

The library is available on PyPI and can be installed using pip:

```bash
pip install pyvint
```

## Usage

### Encoding (Integer to VINT)

```python
import pyvint

vint = pyvint.encode(2)  # just passing an integer returns the minimum length VINT
print(vint)  # b'\x82'
vint2 = pyvint.encode(2, 2)  # passing an integer and the octet length returns a VINT with the specified octet length
print(vint2)  # b'\x40\x02'
```

### Decoding (VINT to Integer)

```python
import pyvint

value = pyvint.decode(b'\x82')
print(value)  # 2
value2 = pyvint.decode(b'\x40\x02')
print(value2)  # 2
```

`pyvint` also provides decoding of VINTs from a stream of bytes. This is useful when reading VINTs from a file or a network stream.
The `decode_stream` function returns the integer value of the VINT and advances the buffer to the next byte after the VINT.

```python
from io import BytesIO
import pyvint

data = b'\x82\x40\x02'
buffer = BytesIO(data)
value = pyvint.decode_stream(data)
print(value)  # 2
print(buffer.read())  # b'\x40\x02'
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyvint",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "vint, variable-size integer, integer",
    "author": "osoken",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/51/41/93a121d2616e607b77a2ae05ea3ec8262b88cf3effe0bec3eba32e995b34/pyvint-1.1.2.tar.gz",
    "platform": null,
    "description": "# pyvint\n\nA pure Python library for encoding and decoding Variable-Sized Integer (VINT) values.\nVINT is used in EBML (Extensible Binary Meta Language) to encode integers with a variable number of bytes.\nDetailed information about VINT can be found in the [Extensible Binary Meta Language RFC 8794](https://datatracker.ietf.org/doc/rfc8794/)\n\n## Installation\n\nThe library is available on PyPI and can be installed using pip:\n\n```bash\npip install pyvint\n```\n\n## Usage\n\n### Encoding (Integer to VINT)\n\n```python\nimport pyvint\n\nvint = pyvint.encode(2)  # just passing an integer returns the minimum length VINT\nprint(vint)  # b'\\x82'\nvint2 = pyvint.encode(2, 2)  # passing an integer and the octet length returns a VINT with the specified octet length\nprint(vint2)  # b'\\x40\\x02'\n```\n\n### Decoding (VINT to Integer)\n\n```python\nimport pyvint\n\nvalue = pyvint.decode(b'\\x82')\nprint(value)  # 2\nvalue2 = pyvint.decode(b'\\x40\\x02')\nprint(value2)  # 2\n```\n\n`pyvint` also provides decoding of VINTs from a stream of bytes. This is useful when reading VINTs from a file or a network stream.\nThe `decode_stream` function returns the integer value of the VINT and advances the buffer to the next byte after the VINT.\n\n```python\nfrom io import BytesIO\nimport pyvint\n\ndata = b'\\x82\\x40\\x02'\nbuffer = BytesIO(data)\nvalue = pyvint.decode_stream(data)\nprint(value)  # 2\nprint(buffer.read())  # b'\\x40\\x02'\n```\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python library for pure Python encoding and decoding of integers using Variable-Size Integer (VINT).",
    "version": "1.1.2",
    "project_urls": {
        "Documentation": "https://osoken.github.io/pyvint/",
        "Source": "https://github.com/osoken/pyvint"
    },
    "split_keywords": [
        "vint",
        " variable-size integer",
        " integer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "246b02948158eb4db55f663a9029f2c738469e6451079d2827d89f0a30154d2a",
                "md5": "041e8bad30540c0f7fe34e6d84aa0e8f",
                "sha256": "c04954bf6212356f9877444fe7b022a1c9ab50ce18e81dbdbcceb1a908fcacc3"
            },
            "downloads": -1,
            "filename": "pyvint-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "041e8bad30540c0f7fe34e6d84aa0e8f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4387,
            "upload_time": "2024-07-04T14:10:50",
            "upload_time_iso_8601": "2024-07-04T14:10:50.166973Z",
            "url": "https://files.pythonhosted.org/packages/24/6b/02948158eb4db55f663a9029f2c738469e6451079d2827d89f0a30154d2a/pyvint-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "514193a121d2616e607b77a2ae05ea3ec8262b88cf3effe0bec3eba32e995b34",
                "md5": "6564be11d1bf9b20ba4391c712d6e729",
                "sha256": "8b15d18719ec34d2aa51e1a1b0ee269704a7cf97b78b299964aaf56d60e79c62"
            },
            "downloads": -1,
            "filename": "pyvint-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "6564be11d1bf9b20ba4391c712d6e729",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4410,
            "upload_time": "2024-07-04T14:10:51",
            "upload_time_iso_8601": "2024-07-04T14:10:51.427832Z",
            "url": "https://files.pythonhosted.org/packages/51/41/93a121d2616e607b77a2ae05ea3ec8262b88cf3effe0bec3eba32e995b34/pyvint-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-04 14:10:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "osoken",
    "github_project": "pyvint",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyvint"
}
        
Elapsed time: 0.27495s