LEB128(Little Endian Base 128)
Project description
LEB128
LEB128 or Little Endian Base 128 is a form of variable-length code compression used to store an arbitrarily large integer in a small number of bytes. LEB128 is used in the DWARF debug file format and the WebAssembly binary encoding for all integer literals.
$ pip3 install leb128
leb128 is used in pywasm, which the WebAssembly virtual machine.
Example
import leb128
# unsigned leb128
assert leb128.u.encode(624485) == bytearray([0xe5, 0x8e, 0x26])
assert leb128.u.decode(bytearray([0xe5, 0x8e, 0x26])) == 624485
# signed leb128
assert leb128.i.encode(-123456) == bytearray([0xc0, 0xbb, 0x78])
assert leb128.i.decode(bytearray([0xc0, 0xbb, 0x78])) == -123456
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
leb128-1.0.3.tar.gz
(2.3 kB
view details)
File details
Details for the file leb128-1.0.3.tar.gz.
File metadata
- Download URL: leb128-1.0.3.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74e70112e7b5b98e57b960d35b86e39c5d17e37298705754675ca88f5a937f73
|
|
| MD5 |
9ab96e7761403cb2379ea67ce1ab5d05
|
|
| BLAKE2b-256 |
bc90d8184bb5680e342a81ceef10aa66538ad923b31e08eb2cfcf87ccdc4d30e
|