Skip to main content

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

Project description

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.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'

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

pyleb128-0.1.3.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

pyleb128-0.1.3-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file pyleb128-0.1.3.tar.gz.

File metadata

  • Download URL: pyleb128-0.1.3.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.4 Windows/10

File hashes

Hashes for pyleb128-0.1.3.tar.gz
Algorithm Hash digest
SHA256 99dad3b457706bc00451480218403ffea104a9ba54bb68d0ba96227d95da3cb6
MD5 f28626852708922f34bdced6beba9c4f
BLAKE2b-256 0905c5a9559258f22283f029974ae514cce1ac3d462adb5a718f65cd4b3462a5

See more details on using hashes here.

File details

Details for the file pyleb128-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyleb128-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.4 Windows/10

File hashes

Hashes for pyleb128-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b4bda71f3df84dc4d7bdfe1af3f9f9ea8603a7517539eb76471f5d235cf520c1
MD5 e8c37bceba43564a43c151d7540c0046
BLAKE2b-256 f4a7c4467e54a075b53c5912f8d2263e37062b1d2f94794b0df4c743847f4b73

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