Repository navigation
xmojo v0.2.0
xmojo v0.2.0
Released: 2026-10-29 · Commit: a76920f · Previous: v0.1.0
What it does
XML for Mojo: parse into your own structs (from_xml[T]), write them back (to_xml), stream big
documents record by record (Records), or walk a compact tree (parse -> Doc). Structs are
walked with Mojo's standard reflection module; no dependency beyond the standard library. Every gate run checks the
parser against CPython's expat on 4,030 generated, mutated and real documents. Library only,
Mojo 1.2.0, linux-64; pixi install and -I src, or the conda package from recipe.yaml.
Highlights
- Builds on Mojo 1.2.0. v0.1.0 could not: its dependency emberserde 0.1.0 ships a file precompiled by Mojo 1.1.0 that 1.2.0 refuses.
- No third-party dependency: decoding and encoding are xmojo's own, over Mojo's standard
reflectionmodule. - Same
from_xml[T]/to_xmlbehaviour and the same modifiers (Rename,RenameAll,Skip,Defaulted,Field[..., extra_names=...],DenyUnknownFields,ArmName), now imported fromxmojo.
Changes
Changed
- Breaking: the modifiers import from
xmojoinstead ofemberserde:from xmojo import Rename, Skip, Defaulted, Field, RenameAll, RenamePolicy, DenyUnknownFields, ArmName. - Breaking: decode and encode errors are plain
Errorvalues with the same text as before (for examplemissing field: id,xmojo: unknown element <extra>), not emberserde'sDeserializationError/SerializationError. - Pin moves to Mojo 1.2.0 (
pixi.toml,recipe.yaml,pixi.lock).
Removed
- The emberserde dependency. A struct set up for EmberJson no longer decodes from XML through the shared framework; it still decodes through xmojo's own rules.
Verified
| Check | Result |
|---|---|
pixi run gate on Mojo 1.2.0: unit tests, tool builds, expat differential (2 seeds), negative control, README snippets |
PASS: 35/35 tests, 2015/2015 twice, negative control 53/215 differ |
| Same gate on Mojo 1.1.0 with emberserde removed | PASS, same counts |
from_xml 80k items, same session, best of 5: v0.1.0 (1.1.0 + emberserde) vs v0.2.0 (1.2.0) |
28.3-28.9 ms vs 28.3-28.9 ms; peak RSS 27.4 MB vs 24.7 MB |
Known limits
- Parsing 80k sibling elements is about 5% slower on Mojo 1.2.0 than on 1.1.0 (16.8 vs 17.7 ms, same session); the parser did not change.
- Only unit
Variantarms, scalarSIMDfields andStringmap keys, as in v0.1.0.
Upgrade / run
pixi install # Mojo 1.2.0
# in your code: from emberserde import Rename -> from xmojo import Rename
Commits
a76920fdocs: README for the own reflection layer and Mojo 1.26dc218cbuild: Mojo 1.2.00e9dad3refactor!: own reflection layer, drop emberserdecf11d2adocs: NOTICE names the owner and contactf45bf4dpublish-check: lint workflows with actionlint7bc529epublish-check: fail on workflow actions pinned to a deprecated runtimef2b695dci: actions/checkout v7 (node24)