Rust-backed xmltodict-compatible XML parser/emitter with PyO3 bindings
Project description
orxml
Rust-backed XML ↔ Python dict conversion, API-compatible with the common surface of [xmltodict](https://github.com/martinblech/xmltodict). ~4× faster on parse and ~10× faster on unparse across a representative corpus.
Uses the BadgerFish-lite convention:
@ prefix for attributes, #text for text content, lists for repeated sibling elements. Because the shape is JSON-compatible, any parsed dict feeds straight into json.dumps.
Install (from source)
git clone https://github.com/bohdanhr/orxml
cd orxml
uv sync
uv run maturin develop --release
Requires a stable Rust toolchain and Python 3.11+.
Usage
import orxml
doc = orxml.parse("<a prop='x'>hello</a>")
# {'a': {'@prop': 'x', '#text': 'hello'}}
xml = orxml.unparse(doc)
Supported options
parse: attr_prefix, cdata_key, force_cdata (bool / tuple / list), cdata_separator, strip_whitespace, namespace_separator, process_namespaces, namespaces, process_comments, comment_key, force_list (bool / tuple / list), disable_entities, xml_attribs.
unparse: attr_prefix, cdata_key, comment_key, namespaces, namespace_separator, pretty, newl, indent (str or int), full_document, short_empty_elements, encoding.
Out-of-scope options (postprocessor, item_callback / item_depth streaming, callable force_list / force_cdata, dict_constructor, preprocessor, expand_iter, file-like / generator inputs) raise NotImplementedError if passed. Unknown options raise TypeError.
Parity
Behavior is matched on the observable surface: for every supported option combination, orxml.parse(xml) == xmltodict.parse(xml) and xmltodict.parse(orxml.unparse(d)) == d. Intentional divergences:
- Exception classes:
orxml.ParseError(aValueError), notxml.parsers.expat.ExpatError. - Error messages and byte-level unparse output (e.g. attribute ordering) are not guaranteed identical.
- Behavior on malformed XML is not defined.
Benchmarks
Run on an Apple Silicon laptop (Python 3.13, xmltodict 0.14, quick-xmltodict 0.2):
| Operation | Fixture | orxml (mean) | xmltodict (mean) | Speedup vs xmltodict |
|---|---|---|---|---|
| parse | tiny.xml | 3.14 µs | 14.02 µs | 4.47× |
| parse | small.xml | 27.37 µs | 117.28 µs | 4.29× |
| parse | rss.xml | 29.55 µs | 124.79 µs | 4.22× |
| parse | soap.xml | 25.46 µs | 97.19 µs | 3.82× |
| parse | large_synthetic.xml | 39.06 ms | 158.14 ms | 4.05× |
| unparse | tiny.xml | 1.07 µs | 11.20 µs | 10.47× |
| unparse | small.xml | 10.36 µs | 107.73 µs | 10.40× |
| unparse | rss.xml | 10.64 µs | 110.94 µs | 10.43× |
| unparse | soap.xml | 8.86 µs | 87.01 µs | 9.82× |
| unparse | large_synthetic.xml | 12.94 ms | 129.03 ms | 9.97× |
orxml.parse also outperforms quick-xmltodict (the other Rust-backed parser) by 1.07–1.50× across these fixtures — e.g. 39.06 ms vs 58.43 ms on large_synthetic.xml.
large_synthetic.xml is ~3 MB / 75k elements / 25k attributes / 40k leaves / 254k text chars. The other fixtures are tens of elements each and are dominated by fixed per-call overhead.
Reproduce locally with make bench.
Development
make sync # uv sync
make build # maturin develop --release
make test # pytest
make bench # pytest-benchmark
make lint # ruff check
make fmt # ruff format
make typecheck # ty check
make all # sync + build + lint + typecheck + test
Corpus
bench/corpus/ holds fixtures used by both tests and benchmarks: tiny.xml, small.xml, rss.xml, soap.xml, and large_synthetic.xml. The last one is generated — regenerate it (or resize it) with:
uv run python bench/corpus/generate_large.py 5000 # ~3 MB
License
MIT
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 orxml-0.2.0.tar.gz.
File metadata
- Download URL: orxml-0.2.0.tar.gz
- Upload date:
- Size: 212.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df11ef4ae8ad839a6fbf7c5456941e5ddb2766a77b52d1dcdc000b704d890d26
|
|
| MD5 |
c58fee4f676ed06fe573d879cdb99769
|
|
| BLAKE2b-256 |
c30c22c98d1de47b1f574b56f7b64eceef244f64681b13e0e84986e8d2cc9606
|
Provenance
The following attestation bundles were made for orxml-0.2.0.tar.gz:
Publisher:
release.yml on bohdanhr/orxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orxml-0.2.0.tar.gz -
Subject digest:
df11ef4ae8ad839a6fbf7c5456941e5ddb2766a77b52d1dcdc000b704d890d26 - Sigstore transparency entry: 1392179049
- Sigstore integration time:
-
Permalink:
bohdanhr/orxml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bohdanhr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Trigger Event:
release
-
Statement type:
File details
Details for the file orxml-0.2.0-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: orxml-0.2.0-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 313.7 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4348cb2bbc234f15685b328c0ac7a638a4005f46d7f4f483e68d82c933c470e1
|
|
| MD5 |
9278a684e719a90391617cccee5f4475
|
|
| BLAKE2b-256 |
000ccdddb8a719de3e4df62c6bb4c8f9255515417ee5455435f93c94cdc8b891
|
Provenance
The following attestation bundles were made for orxml-0.2.0-cp311-abi3-win_amd64.whl:
Publisher:
release.yml on bohdanhr/orxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orxml-0.2.0-cp311-abi3-win_amd64.whl -
Subject digest:
4348cb2bbc234f15685b328c0ac7a638a4005f46d7f4f483e68d82c933c470e1 - Sigstore transparency entry: 1392179114
- Sigstore integration time:
-
Permalink:
bohdanhr/orxml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bohdanhr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Trigger Event:
release
-
Statement type:
File details
Details for the file orxml-0.2.0-cp311-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: orxml-0.2.0-cp311-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 653.2 kB
- Tags: CPython 3.11+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d182667e6ae84178638921a137ab619f59da2aecbc84d614820997a494909e1
|
|
| MD5 |
9abf096d93e10a2795b8dc3736b739d2
|
|
| BLAKE2b-256 |
add7aea21d3a45cf5849f2acef059070120f628ff4df39f0af05eab5c6863e51
|
Provenance
The following attestation bundles were made for orxml-0.2.0-cp311-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on bohdanhr/orxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orxml-0.2.0-cp311-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
9d182667e6ae84178638921a137ab619f59da2aecbc84d614820997a494909e1 - Sigstore transparency entry: 1392179204
- Sigstore integration time:
-
Permalink:
bohdanhr/orxml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bohdanhr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Trigger Event:
release
-
Statement type:
File details
Details for the file orxml-0.2.0-cp311-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: orxml-0.2.0-cp311-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 618.6 kB
- Tags: CPython 3.11+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0eda90f61e2423687a506c41483d5352fadfda9455b014df7e829093d737c86e
|
|
| MD5 |
935c58fc3c9da3e4dbfb8f484340b029
|
|
| BLAKE2b-256 |
f27294e3c4011643de9c47527ce99f5160a38be185df46b6f9e04d804acc1ab2
|
Provenance
The following attestation bundles were made for orxml-0.2.0-cp311-abi3-musllinux_1_2_aarch64.whl:
Publisher:
release.yml on bohdanhr/orxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orxml-0.2.0-cp311-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
0eda90f61e2423687a506c41483d5352fadfda9455b014df7e829093d737c86e - Sigstore transparency entry: 1392179168
- Sigstore integration time:
-
Permalink:
bohdanhr/orxml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bohdanhr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Trigger Event:
release
-
Statement type:
File details
Details for the file orxml-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: orxml-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 439.5 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a1aae635bf5b6f28508c89149e3c04abc7dac1df8d65db815a9f7bbe318312b
|
|
| MD5 |
62d9cd6736e1ce2af80866814a47b9a4
|
|
| BLAKE2b-256 |
752cbfaa2e5777181b2cf059cbdd52ed8ef393c1971388e80beb2e42d5e806af
|
Provenance
The following attestation bundles were made for orxml-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on bohdanhr/orxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orxml-0.2.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
5a1aae635bf5b6f28508c89149e3c04abc7dac1df8d65db815a9f7bbe318312b - Sigstore transparency entry: 1392179144
- Sigstore integration time:
-
Permalink:
bohdanhr/orxml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bohdanhr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Trigger Event:
release
-
Statement type:
File details
Details for the file orxml-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: orxml-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 440.7 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e589038cbe094e30544d911bfa9591a71a7fbb1ef672de4a22898eb7ecb20ddf
|
|
| MD5 |
a80877d3a856d509f4731dc3deb949f4
|
|
| BLAKE2b-256 |
fc6268dbddd596f9ee843e0071437109474d25a9a3578afe7b98706d4e8cbbe1
|
Provenance
The following attestation bundles were made for orxml-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on bohdanhr/orxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orxml-0.2.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
e589038cbe094e30544d911bfa9591a71a7fbb1ef672de4a22898eb7ecb20ddf - Sigstore transparency entry: 1392179082
- Sigstore integration time:
-
Permalink:
bohdanhr/orxml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bohdanhr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Trigger Event:
release
-
Statement type:
File details
Details for the file orxml-0.2.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: orxml-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 408.4 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0709f40857847867dcf881dfe754c29c9249e156ffbcd51e43691055d921b48d
|
|
| MD5 |
02f26ef2d0ad9f4da268f2e18a3fc4ff
|
|
| BLAKE2b-256 |
642fe742d8312e0432468afeb0d9a3779b7ed739d2628ea6616cb8de94478431
|
Provenance
The following attestation bundles were made for orxml-0.2.0-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on bohdanhr/orxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orxml-0.2.0-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
0709f40857847867dcf881dfe754c29c9249e156ffbcd51e43691055d921b48d - Sigstore transparency entry: 1392179230
- Sigstore integration time:
-
Permalink:
bohdanhr/orxml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bohdanhr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Trigger Event:
release
-
Statement type:
File details
Details for the file orxml-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: orxml-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 412.1 kB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25caeef78f483a95420400b3d887666cfb82ad1b6870c307b2d066afa49f01b8
|
|
| MD5 |
8f6e41fab359ab04bda9f20abc8f6685
|
|
| BLAKE2b-256 |
7906f194d246648cc08ecdb55db0d42e51924697369cf2ff85ced1750a49721e
|
Provenance
The following attestation bundles were made for orxml-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on bohdanhr/orxml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orxml-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl -
Subject digest:
25caeef78f483a95420400b3d887666cfb82ad1b6870c307b2d066afa49f01b8 - Sigstore transparency entry: 1392179064
- Sigstore integration time:
-
Permalink:
bohdanhr/orxml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bohdanhr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91d7063e123725cf3679e0d67c1a1f0b89696560 -
Trigger Event:
release
-
Statement type: