Skip to main content

Table of Contents

Varint encoder/decoder

varints are a common encoding for variable length integer data, used in libraries such as sqlite, protobuf, v8, and more. Here's a quick and dirty module to help avoid reimplementing the same thing over and over again.

Taken from https://github.com/fmoo/python-varint/blob/master/varint.py

MIT License

encode

encode(number)

Pack number into varint bytes

decode_stream

decode_stream(stream)

Read a varint from stream. Returns None if an EOF is encountered

decode_bytes

decode_bytes(buf)

Read a varint from from buf bytes

Prefooter Illustration Mobile
Run AI With Certainty
Get started for free
Prefooter Illustration