--- id: leb128 version: "1.0.9" 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) license_treatment: permissive maintenance: active --- # leb128 — LEB128(Little Endian Base 128) License: permissive · Maintenance: active · Downloads: 3.5M/mo ## 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 above — 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 pip install leb128 uv add leb128 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: unspecified - Install friction: low - Maintenance: active - Downloads: 3.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags leb128 encoding decoding, variable length integer compression, webassembly binary format, dwarf debug format, little endian base 128, integer varint encoding, signed unsigned leb128, binary-encoding, webassembly, compression [View on SkillFed](https://skillfed.io/packages/leb128) · [View on PyPI](https://pypi.org/project/leb128/)