ry
raw JSON → 0.0.91 verified Sat May 09 auth: no python
ry ("rust | python") is a high-performance Python library providing Rust-accelerated bindings for hashing, encoding, UUID generation, HTTP client, and more. Current version 0.0.91. Frequent releases (multiple per month), pre-1.0 rapid development.
pip install ry Common errors
error ImportError: cannot import name 'Hash' from 'ry' ↓
cause Hash is not a direct attribute; it's a class inside ry module.
fix
Use
from ry import r#ry.Hash or simply import ry; ry.Hash. error ry.Client() does not support async/await ↓
cause ry.Client is synchronous and blocks.
fix
Use
await asyncio.to_thread(client.request, 'GET', url) or switch to httpx for async. error AttributeError: module 'ry' has no attribute 'uuid' ↓
cause Function renamed or removed; use ry.uuid4() instead.
fix
Replace
ry.uuid() with ry.uuid4(). error SSLCertVerificationError when using ry.Client() ↓
cause Default TLS settings may be strict.
fix
Set
client = ry.Client(verify=False) or configure custom CA bundle. Warnings
gotcha ry.Client() is a synchronous HTTP client. It uses Python threads and may block the event loop if used in async code. Do not call ry.Client() from async tasks without wrapping in a thread executor. ↓
fix Use asyncio.to_thread() to run ry.Client().request() or use a dedicated async HTTP library.
breaking The library is pre-1.0; breaking changes can occur in minor/patch releases. For example, the hash API or encoding functions may change signatures without notice. ↓
fix Pin to a specific version in requirements.txt (e.g., ry==0.0.91). Monitor the changelog before upgrading.
deprecated Some older functions like ry.uuid() (without version) may be deprecated in favor of ry.uuid4(). Check current docs for exact deprecations. ↓
fix Use ry.uuid4() for UUID v4. Use ry.uuid7() for UUID v7 if available.
gotcha Installation may fail without a Rust toolchain because the library is compiled on-the-fly via PyO3. The wheel distribution is not available for all platforms. ↓
fix Install Rust via rustup (https://rustup.rs) or use a Linux x86_64 system where prebuilt wheels may be provided.
Imports
- ry
import ry - ry.Hash wrong
from ry import Hashcorrectimport ry; hash_obj = ry.Hash()
Quickstart
import ry
# Generate a UUID v4
uuid_v4 = ry.uuid4()
print(f"UUID4: {uuid_v4}")
# Compute SHA-256 hash
hash_obj = ry.hash(b"hello", algorithm=ry.HashAlgorithm.SHA256)
print(f"SHA256: {hash_obj.hex()}")
# Encode an object to JSON base64
encoded = ry.json_base64_encode({"key": "value"})
print(f"Encoded: {encoded}")
# Decode it
decoded = ry.json_base64_decode(encoded)
print(f"Decoded: {decoded}")
# Use the HTTP client
client = ry.Client()
response = client.request("GET", "https://httpbin.org/get")
print(f"Status: {response.status_code}")