Varints, a method of serializing integers using one or more bytes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Luke Murphy e6eb8b3746
Fix up README example
10 months ago
pyvarint Add param defs to the doc strings 11 months ago
test Test expected length is produced 11 months ago
.drone.yml Bootstrap pyvarint package 12 months ago
.gitignore Bootstrap pyvarint package 12 months ago
CHANGELOG.md Migrate to pyproject config 11 months ago
LICENSE Bootstrap pyvarint package 12 months ago
README.md Fix up README example 10 months ago
poetry.lock Add missing poetry lock file 11 months ago
pyproject.toml Remove white space 11 months ago

README.md

pyvarint

Build Status

Varints, a method of serializing integers using one or more bytes

Generally in Python, integers are stored as long meaning that they will use at least 32 bits. When storing many numbers which do not require 32 bits, this would seem to be significantly wasteful; variable length representation should be able to assist in such cases.

Install

$ pip install pyvarint

Example

from pyvarint import decode, encode

encoded = encode(666)
decoded = decode(encoded)

print("number: 666", f"encoded: {encoded}", f"decoded: {decoded}", sep="\n")

Output:

number: 666
encoded: b'\x9a\x05'
decoded: 666