Modern XML & JSON Bindings for Python 3.12+
pyxsdata is a complete, modern data binding library for Python 3.12+ allowing developers to access and use XML and JSON documents as simple objects rather than using DOM.
The code generator supports XML schemas, DTD, WSDL definitions, XML & JSON documents. It produces simple dataclasses or Pydantic v2 models with type hints and binding metadata.
The included XML and JSON parser/serializer are highly optimized and adaptable, with multiple handlers and configuration properties.
About pyxsdata (Modern Fork of xsdata)
pyxsdata is a modernized successor and fork of
xsdata designed exclusively for Python 3.12+ and
actively maintained with modern tooling.
Key Enhancements over Legacy xsdata
- Significantly Faster Deserialization: Up to 54% faster in pure Python (over
2x throughput) and up to 15x faster with native Rust acceleration
(
pyxsdata[core]) compared to legacyxsdata. - Unified Native Pydantic v2: Consolidates
xsdata-pydanticdirectly into the core library underpyxsdata.pydanticwith dedicated--output pydanticgeneration and drop-in parsers/serializers. - Python 3.12+ Architecture: Exclusively leverages PEP 695 generics
(
class Foo[T]: ...), type union syntax (X | Y), pattern matching, andkw_onlydataclasses. - Native Rust Acceleration (
pyxsdata-core): First-class zero-copy Rust parser backend achieving ~300,000+ objects/sec (pip install "pyxsdata[core]"). - Ultra-Fast C++ pugixml Support: First-class support for constant-memory
pull-parsing via pugixml (
pip install "pyxsdata[pugixml]"). - Modern Packaging & Tooling: Managed and built with Astral
uv, statically type checked with Astraltywith zero diagnostics, and formatted withruff. - Active & Responsive Maintenance: Regular dependency updates, modern CI packaging, and active community maintenance.
Performance & Deserializer Benchmarks
pyxsdata provides a decoupled, event-driven deserialization architecture supporting
multiple parser backends. You can freely choose between zero-dependency standard library
execution, C/C++ acceleration, or native Rust parsing via
pyxsdata-core.
Deserialization Benchmarks (Standard Python @dataclass)
Parsing 10,000 complex XML items (3.36 MB payload) into nested Python @dataclass
structures:
| Deserializer / Handler | Engine | Extra Dependency | Legacy xsdata |
pyxsdata |
Throughput | Speedup vs Legacy |
|---|---|---|---|---|---|---|
CoreEventHandler / CoreXmlParser |
Rust + PyO3 (quick-xml) |
pyxsdata[core] |
~513.0 ms | 34.4 ms | ~290,700 objs/s | ~15.0x (1,490% faster) |
NativeEventHandler |
Python xml.etree |
None (built-in) | 728.9 ms | 332.5 ms | ~30,075 objs/s | +54.4% (2.2x faster) |
LxmlEventHandler |
C libxml2 (lxml) |
pyxsdata[lxml] |
753.2 ms | 375.2 ms | ~26,650 objs/s | +50.2% (2.0x faster) |
PugixmlEventHandler |
C++ pugixml (pygixml) |
pyxsdata[pugixml] |
883.8 ms | 509.4 ms | ~19,630 objs/s | +42.4% (1.7x faster) |
(Benchmark run on Linux x86_64, CPython 3.12.14, lowest of 5 runs over 10,000 items)
Deserialization Benchmarks (Pydantic v2 BaseModel)
Parsing 1,000 complex XML items into Pydantic v2 BaseModel instances:
| Deserializer | Engine | Latency (1,000 items) | Throughput | Speedup |
|---|---|---|---|---|
CoreXmlParser (pyxsdata.pydantic) |
Rust + PyO3 (quick-xml) |
3.2 ms | ~311,245 objs/s | ~7.67x faster (767%) |
XmlParser (pyxsdata.pydantic) |
Pure Python (xml.etree) |
24.6 ms | ~40,580 objs/s | 1.0x (Baseline) |
Legacy xsdata-pydantic |
Pure Python (xml.etree) |
38.2 ms | ~26,170 objs/s | 0.64x (~11.9x slower vs Core) |
Real-World Enterprise Benchmark: UCI Entity Message
Parsing nested, production-grade Universal Command and Control Interface (UCI v2.5)
Entity telemetry messages (with security markings, timestamps, headers, metadata, and
enums):
| Deserializer | Engine | Latency / Message | Throughput | Speedup |
|---|---|---|---|---|
pyxsdata-core (pyxsdata[core]) |
Rust + PyO3 (quick-xml) |
16.5 µs | ~60,360 msgs/s | ~11.47x (1,047% faster) |
XmlParser (pyxsdata Standard) |
Pure Python (xml.etree) |
190.0 µs | ~5,262 msgs/s | 1.0x (Baseline) |
Which Deserializer Should You Use?
CoreXmlParser/CoreEventHandler(pip install "pyxsdata[core]"): Recommended for high-throughput production systems, real-time APIs, webhooks, and big data feeds. Driven by native Rust (quick-xml), it bypasses intermediate Python DOM objects and maps tokens directly to Python dataclasses or Pydantic models via CPython C-API at ~300,000 objects/second.NativeEventHandler(Built-in standard library): Recommended for zero-dependency deployments, lightweight microservices, and serverless environments (AWS Lambda, Google Cloud Run) where installing C/Rust compilers is undesirable.LxmlEventHandler(pip install "pyxsdata[lxml]"): Ideal for legacy XML workflows requiring schema DTD validation (load_dtd=True), XInclude resolution (process_xinclude=True), or direct parsing fromlxml.etree.Elementtrees.PugixmlEventHandler(pip install "pyxsdata[pugixml]"): Fast C++ pull-parser offering constant-memory streaming for large XML payloads.
Getting started
$ # Install all dependencies including CLI, LXML, SOAP, Pydantic, and native Rust core acceleration
$ pip install "pyxsdata[cli,core,lxml,soap,pydantic]"
$ # Generate models
$ pyxsdata generate tests/fixtures/primer/order.xsd --package tests.fixtures.primer
>>> from tests.fixtures.primer import PurchaseOrder
>>> from pyxsdata.formats.dataclass.parsers import XmlParser, CoreXmlParser
>>>
>>> # Standard pure Python parser:
>>> parser = XmlParser()
>>> order = parser.parse("tests/fixtures/primer/sample.xml", PurchaseOrder)
>>> order.bill_to
Usaddress(name='Robert Smith', street='8 Oak Avenue', city='Old Town', state='PA', zip=Decimal('95819'), country='US')
>>>
>>> # Or ultra-fast Rust-accelerated parser (~290,000+ objs/sec):
>>> core_parser = CoreXmlParser()
>>> order = core_parser.parse("tests/fixtures/primer/sample.xml", PurchaseOrder)
Pydantic Support
Generate Pydantic v2 models directly with --output pydantic:
$ pyxsdata generate tests/fixtures/primer/order.xsd --output pydantic --package myapp.models
>>> from pyxsdata.pydantic.bindings import XmlParser, CoreXmlParser
>>>
>>> # Standard pure Python parser:
>>> parser = XmlParser()
>>> order = parser.from_string(xml_text, PurchaseOrder)
>>> order.model_dump()
>>>
>>> # Or ultra-fast Rust-accelerated parser (~310,000+ objs/sec):
>>> core_parser = CoreXmlParser()
>>> order = core_parser.from_string(xml_text, PurchaseOrder)
>>> order.model_dump()
Check the documentation for more ✨✨✨
Features
Code Generator
- XML Schemas 1.0 & 1.1
- WSDL 1.1 definitions with SOAP 1.1 bindings
- DTD external definitions
- Directly from XML and JSON Documents
- Extensive configuration to customize output
- Pluggable code writer for custom output formats (Standard Dataclasses, Pydantic v2)
Default Output
- Pure Python 3.12+ dataclasses or Pydantic models with metadata
- Modern type hints with support for forward references and unions
- Enumerations and inner classes
- Support namespace qualified elements and attributes
Data Binding
- XML and JSON parser, serializer
- PyCode serializer
- Multiple parser handlers: Native
xml.etree, Clxml, C++pugixml, and Rustpyxsdata-core - Native Rust zero-copy acceleration (
pyxsdata-core) for ~300k objs/sec deserialization - Support wildcard elements and attributes
- Support xinclude statements and unknown properties
- Native Pydantic v2 support (
pyxsdata.pydantic) - Fully type-checked with Astral
ty
Changelog: 0.0.0
- Modernized for Python 3.12+ minimum.
- Consolidated
xsdata-pydanticinto core library aspyxsdata.pydantic. - Replaced mypy with Astral's static type checker
ty. - Standardized CLI tool to
pyxsdata. - Documentation powered by Zensical.
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 pyxsdata-1.2.2.tar.gz.
File metadata
- Download URL: pyxsdata-1.2.2.tar.gz
- Upload date:
- Size: 453.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb034dbadc44fd25cffbea9c5bc91b0684aeb3ecbb4bea634b7d5411ec5ee1b0
|
|
| MD5 |
bc48061a60aab06feea0632a2814da6d
|
|
| BLAKE2b-256 |
b6f59a3e7f37e2a8eca8e5c19203a313f84ff13c80764230a189045f65af7a57
|
File details
Details for the file pyxsdata-1.2.2-py3-none-any.whl.
File metadata
- Download URL: pyxsdata-1.2.2-py3-none-any.whl
- Upload date:
- Size: 249.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4209c50e9baeb4b5ab4efdc81db023d88e1acaadfef74953ec3f1f3fc6fcc9f9
|
|
| MD5 |
78c0aded2143f96fdcfdaf4e37acecd0
|
|
| BLAKE2b-256 |
4db308ec026eaf2ad09d99e762fdc1f48960099a59b17f768492d95790aff705
|