Hi @dapper91,
First off, thank you for building pydantic-xml. It’s an elegant library that bridges the gap between Pydantic and XML seamlessly. I’m a big fan of the project.
I am the creator of pygixml and I believe it could significantly boost parsing performance for pydantic-xml, especially for large payloads.
Why consider pygixml?
- Massive Speedup: It is up to 14x faster than Python’s standard
ElementTree and significantly faster than lxml in many scenarios (up to 8-14x vs stdlib, while lxml is only ~2x vs stdlib).
- Zero Runtime Dependencies: Unlike
lxml, it requires no system libraries (libxml2). It bundles the C++ parser directly.
- Tiny Footprint: 0.45 MB package size vs. 5.5 MB for
lxml.
- Low Memory: Uses ~7x less memory than standard parsers.
Performance Comparison (5,000 elements):
| Library |
Parse Time |
Memory |
Size |
Dependencies |
| pygixml |
0.0009 s |
0.67 MB |
0.45 MB |
None |
| lxml |
0.0041 s |
0.67 MB |
5.48 MB |
libxml2 |
| stdlib (ET) |
0.0083 s |
4.84 MB |
0 MB |
None |
Impact on pydantic-xml:
Since pydantic-xml relies on XML parsing to validate and instantiate models, switching to or supporting pygixml as a backend could reduce latency and memory usage for applications processing large XML documents.
If you are open to this, I’d be happy to help integrate pygixml as an optional backend.
Best regards,
Mohammad Raziei
Creator of pygixml
Hi @dapper91,
First off, thank you for building pydantic-xml. It’s an elegant library that bridges the gap between Pydantic and XML seamlessly. I’m a big fan of the project.
I am the creator of pygixml and I believe it could significantly boost parsing performance for pydantic-xml, especially for large payloads.
Why consider
pygixml?ElementTreeand significantly faster thanlxmlin many scenarios (up to 8-14x vs stdlib, while lxml is only ~2x vs stdlib).lxml, it requires no system libraries (libxml2). It bundles the C++ parser directly.lxml.Performance Comparison (5,000 elements):
Impact on pydantic-xml:
Since pydantic-xml relies on XML parsing to validate and instantiate models, switching to or supporting
pygixmlas a backend could reduce latency and memory usage for applications processing large XML documents.If you are open to this, I’d be happy to help integrate
pygixmlas an optional backend.Best regards,
Mohammad Raziei
Creator of pygixml