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
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
pyvlq-0.1.1.tar.gz
(3.6 kB
view hashes)
Built Distribution
pyvlq-0.1.1-py3-none-any.whl
(3.5 kB
view hashes)