PyRoute: Immutable, hashable, and serializable navigable paths for Python.
Project description
📦 PyRoute
PyRoute is a lightweight module for routing within nested structures. It provides an immutable, hashable path type that you can define, combine, and serialize. One of its use cases is pinpointing the location of a value inside deeply nested data such as dictionaries, json, yaml, ..., in-memory objects, or key-value stores.
✨ Features
| Feature | Description |
|---|---|
| 🔑 Immutable & Hashable | Use Route safely as navigate paths or dict keys |
| 🧩 Composable | Extend with / or + operators |
| 📜 Serializable | Compact Base64URL serialize() / deserialize() |
| 🌀 Pythonic API | Supports iteration, slicing, equality, hashing |
| 👀 Readable | Human-friendly form like <root><a><1><b> |
📦 Installation
A) PyPI
pip install pyroute -U
B) Github
git clone https://github.com/moh-dehghan/pyroute.git
cd pyroute
pip install -e .
🚀 Quick Start
from pyroute import Route
# Create routes
r1 = Route(1, 2, "3")
r2 = Route("x") / "y" + "z"
# Combine
r3 = r1 + r2
print(r3) # <root><1><2><3><x><y><z>
# Iterate
for seg in r3:
print(seg)
# Serialize / Deserialize
serial = r3.serialize()
print("Serialized:", serial)
restored = Route.deserialize(serial)
print("Restored:", restored)
License
This project is licensed under the MIT License – see the LICENSE file for details.
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
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
File details
Details for the file pyroute-1.0.0.tar.gz.
File metadata
- Download URL: pyroute-1.0.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdea0bd2dbb784d21a1a4c96ec30c92a662495d7509c072dc9469ca22be5e764
|
|
| MD5 |
4b9bda8afd81848d8aece0a47b9216f2
|
|
| BLAKE2b-256 |
1b7655c3edc4eaf6ca3f5561c415e1be48af4c26dcbab5e41d776353d147352b
|
File details
Details for the file pyroute-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pyroute-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a037f49c92c38398c138d99e75d952b5a7439264b5047b22e6b2b81682d4a83
|
|
| MD5 |
d0ded8220f5cbd1b465effe3cc955437
|
|
| BLAKE2b-256 |
bedaec61e735c15b9dab2a36bc8dbf7e1230ab709013b69931eea559bc8f8154
|