skillfed

leb128

LEB128(Little Endian Base 128)

leb128 v1.0.9 3.5M downloads/30d#2,581 on PyPI31
Permissive license MIT License Copyright (c) 2021 Mohanson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in… (full text in the JSON record) Active released

What it is and what it does

LEB128 is a variable-length integer encoding scheme that compresses arbitrarily large integers into a small number of bytes. This package provides Python functions to encode and decode both signed and unsigned integers in LEB128 format, with support for streaming decoding via file-like objects.

The format is used in two major contexts: DWARF debug information (used by debuggers and profilers) and WebAssembly binary encoding (for all integer literals in WASM modules). If you're working with either of these formats or need compact integer serialization, this library handles the encoding/decoding mechanics so you don't have to implement them yourself.

Use it for:

  • Parse or generate WebAssembly binary modules that use LEB128 for integer encoding.
  • Read DWARF debug information from compiled binaries for debugging or analysis tools.
  • Serialize integers compactly in custom binary protocols or file formats.
  • Decode streaming integer data from file-like objects without loading entire buffers.
  • Handle both signed and unsigned integer encoding in a single library.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Encodes and decodes integers using LEB128 (Little Endian Base 128), a variable-length compression format used in DWARF debug files and WebAssembly binary encoding.

Yes. The package is actively maintained, has no dependencies, installs cleanly, carries a permissive MIT license, and solves a specific technical problem (LEB128 encoding/decoding) that you would otherwise need to implement yourself. Use it if you're working with WebAssembly, DWARF debug formats, or need LEB128 compression in your own binary protocols.

Install

leb128 on PyPI

pip

pip install leb128

uv

uv add leb128

poetry

poetry add leb128

Installing leb128

Before you install

Low friction: pure Python wheel with no runtime dependencies. Last commit 2026-03-27 and active maintenance status.

License in practice

MIT License permits unrestricted use, modification, and distribution with only attribution and liability disclaimer required.

Quickstart

import leb128
import io

# Unsigned encoding/decoding
assert leb128.u.encode(624485) == bytearray([0xe5, 0x8e, 0x26])
assert leb128.u.decode(bytearray([0xe5, 0x8e, 0x26])) == 624485

# Signed encoding/decoding
assert leb128.i.encode(-12345) == bytearray([0xc7, 0x9f, 0x7f])
assert leb128.i.decode(bytearray([0xc7, 0x9f, 0x7f])) == -12345

Package facts

License MIT License Copyright (c) 2021 Mohanson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in… (full text in the JSON record) (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 217 days since the last release
Last repo commit
First released
Downloads 3,543,677/month — #2,581 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: leb128-1.0.9-py2.py3-none-any.whl

Tags

leb128 encoding decodingvariable length integer compressionwebassembly binary formatdwarf debug formatlittle endian base 128integer varint encodingsigned unsigned leb128
binary-encodingwebassemblycompression

More Software Development packages