Skip to main content

Efficient XML-to-dict conversion backed by Rust

Project description

quick-xmltodict

Efficient XML-to-dict conversion backed by Rust.

>>> from quick_xmltodict import parse

>>> xml = """
... <movies>
...     <movie>
...         <title>Her</title>
...         <director>Spike Jonze</director>
...         <year>2013</year>
...         <genre>Science Fiction, Drama, Romance</genre>
...     </movie>
...     <movie>
...         <title>Encanto</title>
...         <director>Byron Howard, Jared Bush</director>
...         <year>2021</year>
...         <genre>Animation, Family, Fantasy</genre>
...     </movie>
... </movies>
... """

>>> parse(xml)

{'movies': {'movie': [{'director': 'Spike Jonze',
                       'genre': 'Science Fiction, Drama, Romance',
                       'title': 'Her',
                       'year': '2013'},
                      {'director': 'Byron Howard, Jared Bush',
                       'genre': 'Animation, Family, Fantasy',
                       'title': 'Encanto',
                       'year': '2021'}]}}

Features

quick-xmltodict is a Rust-backed XML-to-dict conversion package designed to be fast and efficient. It has a single function, parse, that takes an XML string and returns a Python dictionary. You should be able to use this function as a drop-in replacement for the xmltodict.parse function from the original xmltodict package (used without any extra arguments). Like xmltodict, quick-xmltodict follows this schema for converting XML to JSON.

quick-xmltodict currently does not support namespace expansion, or the reverse operation (dict-to-XML conversion). For these features, use the original xmltodict package.

Performance

Since xmltodict uses the non-validating C-based expat parser from Python's standard library, it is already very fast. quick-xmltodict is nonetheless about 2-5 times faster than xmltodict.

Contributing

PRs are very welcome! Please make sure to run the tests before submitting a PR.

Development

This project uses Poetry to manage the environment and Python dependencies, so you'll need to have it installed in addition to Python and Rust.

To install the development environment and run the test suite:

poetry install
poetry run maturin develop
poetry run pytest

Be sure to run poetry run maturin develop after making changes to the Rust code. Add the -r flag for a release build (for example, if you want to run benchmarks).

It's recommended to install the pre-commit hooks:

poetry run pre-commit install

This ensures that linting and formatting are run automatically on every commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quick_xmltodict-0.1.2.tar.gz (4.8 MB view hashes)

Uploaded Source

Built Distributions

quick_xmltodict-0.1.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (225.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

quick_xmltodict-0.1.2-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (322.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

quick_xmltodict-0.1.2-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (243.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

quick_xmltodict-0.1.2-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (218.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

quick_xmltodict-0.1.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl (232.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

quick_xmltodict-0.1.2-cp312-none-win_amd64.whl (136.1 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

quick_xmltodict-0.1.2-cp312-none-win32.whl (130.8 kB view hashes)

Uploaded CPython 3.12 Windows x86

quick_xmltodict-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (225.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

quick_xmltodict-0.1.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (321.0 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

quick_xmltodict-0.1.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (242.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

quick_xmltodict-0.1.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (217.9 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

quick_xmltodict-0.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (216.5 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

quick_xmltodict-0.1.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (231.7 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.5+ i686

quick_xmltodict-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (200.9 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

quick_xmltodict-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl (207.2 kB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

quick_xmltodict-0.1.2-cp311-none-win_amd64.whl (136.0 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

quick_xmltodict-0.1.2-cp311-none-win32.whl (130.7 kB view hashes)

Uploaded CPython 3.11 Windows x86

quick_xmltodict-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (225.3 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

quick_xmltodict-0.1.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (322.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

quick_xmltodict-0.1.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (242.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

quick_xmltodict-0.1.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (218.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

quick_xmltodict-0.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (216.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

quick_xmltodict-0.1.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (232.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

quick_xmltodict-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (201.2 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

quick_xmltodict-0.1.2-cp311-cp311-macosx_10_12_x86_64.whl (207.6 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

quick_xmltodict-0.1.2-cp310-none-win_amd64.whl (136.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

quick_xmltodict-0.1.2-cp310-none-win32.whl (130.7 kB view hashes)

Uploaded CPython 3.10 Windows x86

quick_xmltodict-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (225.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

quick_xmltodict-0.1.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (322.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

quick_xmltodict-0.1.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (242.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

quick_xmltodict-0.1.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (218.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

quick_xmltodict-0.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (216.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

quick_xmltodict-0.1.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (232.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

quick_xmltodict-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (201.1 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

quick_xmltodict-0.1.2-cp310-cp310-macosx_10_12_x86_64.whl (207.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page