whylogs.util.varint

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

Module Contents

Functions

_byte(b)

encode(number)

Pack number into varint bytes

decode_stream(stream)

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

decode_bytes(buf)

Read a varint from from buf bytes

_read_one(stream)

Read a byte from the file (as an integer)

whylogs.util.varint._byte(b)
whylogs.util.varint.encode(number)

Pack number into varint bytes

whylogs.util.varint.decode_stream(stream)

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

whylogs.util.varint.decode_bytes(buf)

Read a varint from from buf bytes

whylogs.util.varint._read_one(stream)

Read a byte from the file (as an integer) raises EOFError if the stream ends while reading bytes.