Skip to main content

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 has been used in pywasm and emscripten.

Example

import io
import leb128

# unsigned leb128
assert leb128.u.encode(624485) == bytearray([0xe5, 0x8e, 0x26])
assert leb128.u.decode(bytearray([0xe5, 0x8e, 0x26])) == 624485
assert leb128.u.decode_reader(io.BytesIO(bytearray([0xe5, 0x8e, 0x26]))) == (624485, 3)

#   signed leb128
assert leb128.i.encode(-12345) == bytearray([0xc7, 0x9f, 0x7f])
assert leb128.i.decode(bytearray([0xc7, 0x9f, 0x7f])) == -12345
assert leb128.i.decode_reader(io.BytesIO(bytearray([0xc7, 0x9f, 0x7f]))) == (-12345, 3)

License

MIT

Project details


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.8.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

leb128-1.0.8-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file leb128-1.0.8.tar.gz.

File metadata

  • Download URL: leb128-1.0.8.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for leb128-1.0.8.tar.gz
Algorithm Hash digest
SHA256 3a52dca242f93f87a3d766380a93a3fad53ef4044f03018d21705d3b2d9021ee
MD5 96d7fc6e95af1e8448763153b8567da1
BLAKE2b-256 433b476c8bcb181abb060e45bca5ce9b5ba055ea9e2ed3fac6c25b2fe7b9f16b

See more details on using hashes here.

File details

Details for the file leb128-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: leb128-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for leb128-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 76cd271e75ea91aa2fbf7783d60cb7d667b62143d544bcee59159ff258bf4523
MD5 478a104ca1e56a2bc18e48e990183508
BLAKE2b-256 099745ab4bab1a89e6fdbc822f818bb18b39eed0dd7ed1faac8b89bc6b49a9ed

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page