Python bindings for Rusty Object Notation
Project description
pyron
Python bindings for the Rusty Object Notation.
Development
Build and test locally with uv:
uv sync --group dev --no-install-project
cargo generate-lockfile
cargo check --locked --all-targets
rm -rf dist
uv run --no-sync maturin build --release --locked --out dist
PYTHON=$(uv run --no-sync python -c 'import sys; print(sys.executable)')
uv pip install --python "$PYTHON" --reinstall --no-deps dist/*.whl
uv run --no-sync python test.py
uv run --no-sync pytest
Here's a paste-ready README section:
Usage
python-ron exposes a small API for converting between RON text and Python objects.
import pyron
Parse RON from a string
import pyron
text = """
Config(
name: "demo",
enabled: true,
steps: [
(0, 0.0005),
"lin",
(1, 0),
],
)
"""
obj = pyron.loads(text)
print(obj)
By default, named RON structs are converted to plain Python dictionaries:
>>> pyron.loads('Point(x: 1, y: 2)')
{'x': 1, 'y': 2}
Preserve RON struct names
Use preserve_class_names=True when you need to retain the RON type name:
>>> pyron.loads('Point(x: 1, y: 2)', preserve_class_names=True)
('Point', {'x': 1, 'y': 2})
Use preserve_structs=True to convert named RON structs to Python namedtuple instances:
>>> point = pyron.loads('Point(x: 1, y: 2)', preserve_structs=True)
>>> point
Point(x=1, y=2)
>>> point.x
1
Parse RON from a file
import pyron
config = pyron.load("config.ron")
The same options accepted by loads are also accepted by load:
config = pyron.load("config.ron", preserve_class_names=True)
Serialize Python objects to RON
import pyron
obj = {
"name": "demo",
"enabled": True,
"steps": [
(0, 0.0005),
"lin",
(1, 0),
],
}
text = pyron.to_string(obj)
print(text)
Supported Python input types include:
Noneboolintfloatstrlisttupledict- dataclass instances
namedtupleinstances
Round trip example
import pyron
original = {
"schedule": [
(0, 0.0005),
"lin",
(1, 0),
],
}
text = pyron.to_string(original)
restored = pyron.loads(text)
assert restored == original
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 Distributions
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 python_ron-0.2.7.tar.gz.
File metadata
- Download URL: python_ron-0.2.7.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5766524c4e455643f6f4b42d56fb9d66ca037514561603733dc6454891c5b725
|
|
| MD5 |
726fd3923b7549207ad80d84cf39338c
|
|
| BLAKE2b-256 |
1dbfe51e284b07f8d2052883d4431b3b4a8c3d7eddd8a393a353ba8d56798317
|
File details
Details for the file python_ron-0.2.7-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: python_ron-0.2.7-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 280.7 kB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93d9c6ab3a9afa4973861627d554b6aec49be9eda11328627239e159a26bb56b
|
|
| MD5 |
6b1a13573a468ba06c524e40c9d049e3
|
|
| BLAKE2b-256 |
531dc800d47968e653d8533c50678f1074702d112c43e499c6103000619cb308
|
File details
Details for the file python_ron-0.2.7-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: python_ron-0.2.7-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 298.5 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec9393784e165e2dd9bf7accb879f55bef40177b2dd4217c57545359abc81d7c
|
|
| MD5 |
d55abef5ff347df6d310107886e4955e
|
|
| BLAKE2b-256 |
2e85e212f1dad3f54441c895f90fc26db0228d9c6489defecb91976e21577f33
|
File details
Details for the file python_ron-0.2.7-cp310-abi3-win32.whl.
File metadata
- Download URL: python_ron-0.2.7-cp310-abi3-win32.whl
- Upload date:
- Size: 278.6 kB
- Tags: CPython 3.10+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95a113f063842b954b079a18d38427e0b287c3d6b1af8c03e4b184c91657f102
|
|
| MD5 |
a4282f4a25d65943623c01918e8450ad
|
|
| BLAKE2b-256 |
4e9c7e2e61c93b704606f8776a18c81780e73bbb01f13653928aad98637132d8
|
File details
Details for the file python_ron-0.2.7-cp310-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: python_ron-0.2.7-cp310-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 598.0 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75c6af3f8039597fdc20e22fe9f6422b74e957e8eb0e8de52c11cbb3b87df656
|
|
| MD5 |
53ed36375288f876e375a25895065e2b
|
|
| BLAKE2b-256 |
79a9cb30ad475161e947ea1b65197799035bac31a75da9eca6913633b2a7e932
|
File details
Details for the file python_ron-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: python_ron-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 363.0 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f22b3f189b74273b70abed594727fa7cc6b987c7b6858794ab7d3f9b058f5e3
|
|
| MD5 |
fee90078e32efb44324cc4c7f45abfc1
|
|
| BLAKE2b-256 |
82825e92a6e227f56bc21468ab56d15ef36a0b60e307099e020ea3e0b7f4493c
|