Skip to main content

pyron

PyPI

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:

  • None
  • bool
  • int
  • float
  • str
  • list
  • tuple
  • dict
  • dataclass instances
  • namedtuple instances

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

Release files for python-ron 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-ron 0.2.7
File Size Uploaded
python_ron-0.2.7.tar.gz 20.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for python-ron 0.2.7
File
python_ron-0.2.7-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
python_ron-0.2.7-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
python_ron-0.2.7-cp310-abi3-win32.whl CPython 3.10 abi3 Windows x86-32 Details
python_ron-0.2.7-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
python_ron-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 1.8 MB

Release files / python_ron-0.2.7.tar.gz

Download URL python_ron-0.2.7.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5766524c4e455643f6f4b42d56fb9d66ca037514561603733dc6454891c5b725
BLAKE2b-256 checksum
How to use checksums
1dbfe51e284b07f8d2052883d4431b3b4a8c3d7eddd8a393a353ba8d56798317
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / python_ron-0.2.7-cp310-abi3-win_arm64.whl

Download URL python_ron-0.2.7-cp310-abi3-win_arm64.whl
Size 280.7 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
93d9c6ab3a9afa4973861627d554b6aec49be9eda11328627239e159a26bb56b
BLAKE2b-256 checksum
How to use checksums
531dc800d47968e653d8533c50678f1074702d112c43e499c6103000619cb308
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / python_ron-0.2.7-cp310-abi3-win_amd64.whl

Download URL python_ron-0.2.7-cp310-abi3-win_amd64.whl
Size 298.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ec9393784e165e2dd9bf7accb879f55bef40177b2dd4217c57545359abc81d7c
BLAKE2b-256 checksum
How to use checksums
2e85e212f1dad3f54441c895f90fc26db0228d9c6489defecb91976e21577f33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / python_ron-0.2.7-cp310-abi3-win32.whl

Download URL python_ron-0.2.7-cp310-abi3-win32.whl
Size 278.6 kB
Tags CPython 3.10 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
95a113f063842b954b079a18d38427e0b287c3d6b1af8c03e4b184c91657f102
BLAKE2b-256 checksum
How to use checksums
4e9c7e2e61c93b704606f8776a18c81780e73bbb01f13653928aad98637132d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / python_ron-0.2.7-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL python_ron-0.2.7-cp310-abi3-musllinux_1_2_x86_64.whl
Size 598.0 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
75c6af3f8039597fdc20e22fe9f6422b74e957e8eb0e8de52c11cbb3b87df656
BLAKE2b-256 checksum
How to use checksums
79a9cb30ad475161e947ea1b65197799035bac31a75da9eca6913633b2a7e932
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / python_ron-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl

Download URL python_ron-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl
Size 363.0 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4f22b3f189b74273b70abed594727fa7cc6b987c7b6858794ab7d3f9b058f5e3
BLAKE2b-256 checksum
How to use checksums
82825e92a6e227f56bc21468ab56d15ef36a0b60e307099e020ea3e0b7f4493c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release history Release notifications | RSS feed

This release

0.2.7 This release

6 release files

0.2.5

19 release files

0.2.4

14 release files

0.2.3

4 release files

0.2.2

1 release file

0.1.8

13 release files

0.1.7

16 release files

0.1.6

16 release files

0.1.5

16 release files

0.1.1

15 release files

0.1.0

10 release files

0.0.2

12 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page