Skip to main content

pyleb128

Powerful little-endian base-128 encoding/decoding library for Python 3.

Supports the following types:

  • Unsigned LEB128
  • Signed LEB128
  • Unsigned LEB128 +1 (ULEB128P1)

Note

The LEB classes all inherit from int and have all the operations implemented. The type of the result from any int operation will always be the type of the lhs. If the lhs is an int, then the type is an int. If the lhs is a LEB type, then the resulting type is a LEB.

Installing

python -m pip install -U pyleb128

Example Usage

from pyleb128 import uleb128, sleb128

# unsigned
print(uleb128(0xffff).size)  # 2
print((uleb128(0xffff) * 2).encoded)  # b'\xfe\xff\x07'
print(uleb128.decode(b'\xff\xff\x03'))  # 65535
print(uleb128.decode(b'\xff\xff\x03').encoded)  # b'\xff\xff\x03'
print(uleb128.decode(b'\xff\xff\x03', p1=True))  # decode with as ULEB128P1

# signed
print(sleb128.decode(b'\xf3\xff\xff\xff\x0f'))  # -13
print(uleb128.decode(b'\xf3\xff\xff\xff\x0f').encoded)  # b'\xf3\xff\xff\xff\x0f'

# can decode from a binary stream, too:
import io

stream = io.BytesIO(b'\xff\xff\x03') 
print(uleb128.decode_stream(stream, p1=True))

Metadata

Release files for pyleb128 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyleb128 0.2.4
File Size Uploaded Provenance Actions
pyleb128-0.2.4.tar.gz 15.7 kB Without provenance Details for pyleb128-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyleb128 0.2.4
File Interpreter ABI Platform Actions
pyleb128-0.2.4-py3-none-any.whl Python 3 none any Details for pyleb128-0.2.4-py3-none-any.whl

Total release size: 34.3 kB

Release files / pyleb128-0.2.4.tar.gz

Download URL pyleb128-0.2.4.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2bcd3339e65eb319b78acb8036e28a15c8bfee68237f3f42e0c69ea12e252541
BLAKE2b-256 checksum
How to use checksums
26a82cf3d0ec4a73abd8fc2b1e059bb540842c3ca9f927b33099467ea89f38b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.4 Windows/10

Release files / pyleb128-0.2.4-py3-none-any.whl

Download URL pyleb128-0.2.4-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c24de16ef33369e37a26f636f398039e411d13df6a9dc69cda544a7c617ec49
BLAKE2b-256 checksum
How to use checksums
e93bd66071706d5a006f1e7f975ad3ba315f8f1c0ea7f983195cc9453a40f46f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.4 Windows/10

Security for pyleb128 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page