Registry / serialization / base2048

base2048

JSON →
library0.1.3pypypi✓ verified 85d ago

`base2048` is a Python library that provides efficient binary encoding and decoding using the Base2048 scheme, implemented as a Rust extension for performance. It offers simple functions to convert bytes to Base2048 strings and vice-versa. The current version is 0.1.3, and it functions as a stable utility library with infrequent updates, focusing on its core encoding capabilities.

pip install base2048
INSTALL
IMPORT
SIG · BASE2048
B
base2048
serializationpythonv0.1.3
Install
1.6s avg
Import
Disk
20MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.3 · 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.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 22MB
20MB installed
● package 20MB
Code
Verified usage

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

encode
from base2048 import encode
decode
from base2048 import decode

This quickstart demonstrates how to encode `bytes` to a Base2048 string and decode it back. It also shows the necessary steps to handle text (Unicode) by explicitly converting it to bytes before encoding and back to a string after decoding.

from base2048 import encode, decode original_bytes = b"Hello, Base2048 encoding!" # Encode bytes to a Base2048 string encoded_string = encode(original_bytes) print(f"Original bytes: {original_bytes!r}") print(f"Encoded string: {encoded_string!r}") # Decode Base2048 string back to bytes decoded_bytes = decode(encoded_string) print(f"Decoded bytes: {decoded_bytes!r}") assert original_bytes == decoded_bytes # Example with text that needs explicit encoding/decoding text = "こんにちは, Base2048!" text_bytes = text.encode('utf-8') encoded_text_string = encode(text_bytes) print(f"\nOriginal text: {text!r}") print(f"Encoded text string: {encoded_text_string!r}") decoded_text_bytes = decode(encoded_text_string) decoded_text = decoded_text_bytes.decode('utf-8') print(f"Decoded text: {decoded_text!r}") assert text == decoded_text
Debug
Known issues
gotchaThe `base2048.encode()` function strictly expects `bytes` objects as input. Passing a Python `str` directly will result in a `TypeError` because the library operates on raw binary data.
fix
Always convert your string data to `bytes` using an appropriate encoding (e.g., `my_string.encode('utf-8')`) before passing it to `encode()`.
affects: 0.1.x
gotchaThe `base2048.decode()` function strictly expects a Python `str` object (the Base2048 encoded string) as input. Passing a `bytes` object will result in a `TypeError`.
fix
Ensure the input to `decode()` is a `str`. The output of `encode()` is already a `str`, so no conversion is needed for decoding its direct result.
affects: 0.1.x
gotchaBase2048 is a binary encoding scheme and does not intrinsically handle character encodings (like UTF-8, Latin-1, etc.). If you are encoding text, you must explicitly encode your `str` to `bytes` before passing it to `encode()` and then decode the resulting `bytes` back to a `str` after calling `decode()`.
fix
For text, the workflow should be: `text_str.encode('utf-8')` -> `encode()` -> `decode()` -> `decoded_bytes.decode('utf-8')`.
affects: 0.1.x
Errors
Common errors & fixes
TypeError: argument 'data': 'str' object cannot be converted to 'bytes'
Attempting to encode a Python `str` object directly with `base2048.encode()`.
fix
Convert the string to bytes first: `encoded_data = base2048.encode('my string'.encode('utf-8'))`.
TypeError: argument 'data': 'bytes' object cannot be converted to 'str'
Attempting to decode a Python `bytes` object directly with `base2048.decode()`.
fix
The input to `base2048.decode()` must be a Python `str`. Ensure you are passing the string output from `base2048.encode()` or a valid Base2048 string.
ModuleNotFoundError: No module named 'base2048'
The `base2048` library has not been installed in the current Python environment.
fix
Install the library using pip: `pip install base2048`.
Upgrade
Version history
0.1.3latest on PyPI · released Sep 26, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
base2048 — pip install base2048 · libregistry