Varints, a method of serializing integers using one or more bytes
Go to file
Luke Murphy 5d6cd9158d
Remove white space
2020-07-09 10:13:01 +02:00
pyvarint Migrate to pyproject config 2020-07-07 15:59:42 +02:00
test Migrate to pyproject config 2020-07-07 15:59:42 +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
README.md Add a short description 2020-07-09 10:12:54 +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

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 random import sample
from pyvarint import decode, encode

ten_rand_ints = sample(range(100), 10)

for rand_int in ten_rand_ints:
    encoded = encode(rand_int)
    decoded = decode(encoded)
    assert decoded == rand_int