Skip to main content

A Python library for pure Python encoding and decoding of integers using Variable-length quantity.

Project description

pyvlq

pyvlq is a Python library for encoding and decoding Variable-Length Quantity <https://en.wikipedia.org/wiki/Variable-length_quantity>_.

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

pip install pyvlq

Usage

from io import BytesIO
import pyvlq

# Encode
encoded = pyvlq.encode(128)
print(encoded) # b'\x81\x00'

# Decode
decoded = pyvlq.decode(encoded)
print(decoded) # 128

# Decode from readable bytes
buffer = BytesIO(b'\x81\x00\xff\xff')
decoded = pyvlq.decode_stream(buffer)
print(decoded) # 128 (0xff\xff is ignored)
print(buffer.read(2)) # b'\xff\xff' (0xff\xff is left in the buffer)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvlq-0.1.1.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

pyvlq-0.1.1-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page