Skip to content

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

License

Notifications You must be signed in to change notification settings

hyperpy/pyvarint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages