Compact serialization of NumPy uint8 arrays via WebP + base64
Project description
AnyID
Fast, unique, and serializable identifiers for NumPy arrays.
Features
- Stable Deterministic Hash: Generate consistent IDs from NumPy arrays based on data, shape, and dtype.
- Optimized Serialization: Efficient string representation using WebP Lossless compression and Base64 encoding (optimized for
uint8image arrays). - Zero Loss: 100% lossless reconstruction of pixel values and array shapes.
Installation
pip install .
Usage
Generating IDs
import numpy as np
from anyid.id import of_arr
arr = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
id_str = of_arr(arr)
print(id_str) # e.g., 'a1b2c3d4'
Serialization
from anyid.serialize import to_str, to_arr
# Serialize to a compact string
encoded = to_str(arr)
# Deserialize back to a NumPy array
arr_back = to_arr(encoded)
assert np.array_equal(arr, arr_back)
Development
Run tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
imstr-0.1.0.tar.gz
(2.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
imstr-0.1.0-py3-none-any.whl
(2.3 kB
view details)
File details
Details for the file imstr-0.1.0.tar.gz.
File metadata
- Download URL: imstr-0.1.0.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
313686b456520598b2931da9358aa71ed557ce888b6fbf362a87e0f3440c590c
|
|
| MD5 |
55510be26649f6aa2f72ab4ecf4a5df4
|
|
| BLAKE2b-256 |
76393da14372ceebf5102cf4ffc85875ca5766b69f8d966e71e66d0abe518238
|
File details
Details for the file imstr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: imstr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7207308408e176bc54d36f8c3ceca819e0d833f05f0e294a8cb2db1c4dc6ad5
|
|
| MD5 |
5ffec28a03b78fa297f745142993980b
|
|
| BLAKE2b-256 |
7cd386ae7b1712b284b1911ca1462ba9893cbc6baf5299ae31df828fd3d06f77
|