Varints, a method of serializing integers using one or more bytes
Go to file
Luke Murphy e6eb8b3746
All checks were successful
continuous-integration/drone/push Build is passing
Fix up README example
2020-08-05 08:28:38 +02:00
pyvarint Add param defs to the doc strings 2020-07-10 12:36:19 +02:00
test Test expected length is produced 2020-07-09 10:13:07 +02:00
.drone.yml Bootstrap pyvarint package 2020-06-26 17:19:34 +02:00
.gitignore Bootstrap pyvarint package 2020-06-26 17:19:34 +02:00
CHANGELOG.md Migrate to pyproject config 2020-07-07 15:59:42 +02:00
LICENSE Bootstrap pyvarint package 2020-06-26 17:19:34 +02:00
poetry.lock Add missing poetry lock file 2020-07-07 16:00:50 +02:00
pyproject.toml Remove white space 2020-07-09 10:13:01 +02:00
README.md Fix up README example 2020-08-05 08:28:38 +02:00

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