Varints, a method of serializing integers using one or more bytes
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
Luke Murphy e6eb8b3746
Fix up README example
2ヶ月前
pyvarint Add param defs to the doc strings 3ヶ月前
test Test expected length is produced 3ヶ月前
.drone.yml Bootstrap pyvarint package 4ヶ月前
.gitignore Bootstrap pyvarint package 4ヶ月前
CHANGELOG.md Migrate to pyproject config 3ヶ月前
LICENSE Bootstrap pyvarint package 4ヶ月前
README.md Fix up README example 2ヶ月前
poetry.lock Add missing poetry lock file 3ヶ月前
pyproject.toml Remove white space 3ヶ月前

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