Registry / serialization / python-baseconv

python-baseconv

JSON →
library1.2.2pypypi✓ verified 35d ago

Python-baseconv is a lightweight Python module designed to convert numbers from base 10 integers to base X strings and vice versa. It provides predefined converters for common bases like binary, hexadecimal, and Base64, as well as the ability to define custom alphabets. The current version is 1.2.2, with its last release in April 2019, suggesting a maintenance-focused release cadence.

serialization
Install & Compatibility
Where this runs
tested against v1.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.6s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Predefined converters are directly imported from the `baseconv` package, not as submodules of `baseconv` itself.

from baseconv import base2, base16, base36, base56, base58, base62, base64
from baseconv import BaseConverter

This quickstart demonstrates how to use the predefined base converters and how to create a custom BaseConverter with your own alphabet for encoding and decoding integers.

from baseconv import base62, BaseConverter # Using a predefined converter (e.g., Base62) encoded_value = base62.encode(1234567890) print(f"Encoded to Base62: {encoded_value}") decoded_value = base62.decode(encoded_value) print(f"Decoded from Base62: {decoded_value}") # Creating a custom converter my_alphabet = '0123456789ABCDEF' my_hex_converter = BaseConverter(my_alphabet) custom_encoded = my_hex_converter.encode(255) print(f"Custom Hex Encoded: {custom_encoded}") custom_decoded = my_hex_converter.decode(custom_encoded) print(f"Custom Hex Decoded: {custom_decoded}")
Debug
Known footguns
gotchaThe library was originally developed with Python 2.7 in mind, as evidenced by Python 2.7 classifiers on PyPI and use of 'L' suffix for long integers in older examples. While the core functionality generally works in Python 3, active Python 3-specific maintenance might be limited.
deprecatedDo not confuse `python-baseconv` with `django.utils.baseconv`. The latter was a private, undocumented module within Django that borrowed code from `python-baseconv` but has been deprecated in Django 4.0 and completely removed in Django 5.0. Directly importing `django.utils.baseconv` will fail in modern Django versions.
gotchaThe `BaseConverter` class and its methods (`encode`, `decode`) will raise `ValueError` for invalid inputs, such as an empty digit alphabet during instantiation, using a sign character within the digit alphabet, or encountering digits during decoding that are not present in the converter's alphabet.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
10 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
bingbot
1
Resources