Skip to main content

Unsigned variable-length integers

Project description

uvarint

Unsigned variable-length integers.

Usage

import uvarint

buffer = uvarint.encode(16384)                  # b'\x80\x80\x01'
integer, bytes_read = uvarint.decode(buffer)    # 16384

big = uvarint.encode(2 ** 63)
uvarint.decode(big)              # Raises OverflowError; decoder limited to 9 bytes by default
uvarint.decode(big, limit=16)    # Success; use math.inf for unlimited decoding

multiple  = uvarint.encode(100)
multiple += uvarint.encode(200)
multiple += uvarint.encode(300)
uvarint.expect(3, multiple).integers    # [100, 200, 300]

References

License

This module is licensed under the MIT license.

Download files

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

Source Distribution

uvarint-1.1.0.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

uvarint-1.1.0-py3-none-any.whl (4.1 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