Skip to main content

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

Installation

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

pip install pyvint

Usage

Encoding (Integer to VINT)

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)

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.

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'

Metadata

Release files for pyvint 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvint 1.1.2
File Size Uploaded
pyvint-1.1.2.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyvint 1.1.2
File Interpreter ABI Platform
pyvint-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / pyvint-1.1.2.tar.gz

Download URL pyvint-1.1.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8b15d18719ec34d2aa51e1a1b0ee269704a7cf97b78b299964aaf56d60e79c62
BLAKE2b-256 checksum
How to use checksums
514193a121d2616e607b77a2ae05ea3ec8262b88cf3effe0bec3eba32e995b34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.13

Release files / pyvint-1.1.2-py3-none-any.whl

Download URL pyvint-1.1.2-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c04954bf6212356f9877444fe7b022a1c9ab50ce18e81dbdbcceb1a908fcacc3
BLAKE2b-256 checksum
How to use checksums
246b02948158eb4db55f663a9029f2c738469e6451079d2827d89f0a30154d2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.13

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page