python-matchit is a Python binding for the matchit Rust library.
matchit is a high-performance URL/path routing library. It builds a radix tree (compressed trie) from route patterns and finds the best match for a given path in logarithmic time. This makes python-matchit a very fast choice for HTTP routers, URL dispatchers, or any task where you need to match many patterns against paths.
Installation
pip install python-matchit
Usage
from matchit import Router
router = Router[str]()
router.insert("/users/{id}", "test_id")
res = router.at("/users/123")
assert res.value == "test_id"
assert res.params == {"id": "123"}
try:
router.at("/noway")
except LookupError:
print("Not found as expected")
Router() without type argument also works.
Development
Setup
uv sync
Testing
Build and install the package in editable mode, then run tests:
maturin develop --uv
uv run python test.py
Note: use
maturin develop --uv, notuv run maturin develop. The latter runs maturin without telling it to useuvfor installation, which may result in a non-editable install.
Updating matchit
To update the underlying Rust matchit library:
-
Check matchit release notes for breaking changes.
-
Update the version in
Cargo.toml:[dependencies] matchit = "0.10.0"
-
Update
Cargo.lock:cargo update -p matchit
-
Adapt
src/lib.rsif thematchitAPI changed. -
Rebuild and test:
maturin develop --uv uv run python test.py
Building a release
maturin build --release
The built wheel will be placed in dist/.
Release files for python-matchit 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_matchit-0.4.0.tar.gz | 12.2 kB | Details |
Built distributions (wheels)
Total release size: 4.9 MB
Release files / python_matchit-0.4.0.tar.gz
| Download URL | python_matchit-0.4.0.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
783658f44a0459ee0faa6ef84ffc101267d63eea0338cdf517b2d4cf2890f01a
|
|
BLAKE2b-256 checksum How to use checksums |
a3e8ab7c03432f03297d5756feca4aba97cc50c7221881116e422c690ccd653d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-win_arm64.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-win_arm64.whl |
|---|---|
| Size | 146.5 kB |
| Tags | CPython 3.8 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
801b8de925f08d5c1ebc2f6b164a68b1cea1268e586d3d48ad3026a109beb7b3
|
|
BLAKE2b-256 checksum How to use checksums |
e0d26b7c7c180e86d168d7dcd1b13b4e09161a9404832f8f700adfc80a28e001
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-win_amd64.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 149.5 kB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
099853ca05001af3a12f849bae6a96321c3c9d83e77b17663a0230d9020412db
|
|
BLAKE2b-256 checksum How to use checksums |
0cdacdb2768c79fb6fd7ae0c1c4a48ecb41641a9939225583732b07bb6da6265
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-win32.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-win32.whl |
|---|---|
| Size | 140.0 kB |
| Tags | CPython 3.8 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
10a94dcc0d993a437b9d48814e55f2521e97dd7250b97b774f0f611344ec91dd
|
|
BLAKE2b-256 checksum How to use checksums |
93af27b17e1e8e21a13ffab72aff027a42e3e72cafaa6afce45ae993d909526f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-musllinux_1_2_x86_64.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 496.2 kB |
| Tags | CPython 3.8 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e2f5bef2ae9e4301b65117c96c9b585455e4d687935158622fad128a290c6578
|
|
BLAKE2b-256 checksum How to use checksums |
491f17f4534ca9831dff20f57089e4d0476e3a888968c3b984ea59b22a704c9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-musllinux_1_2_i686.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-musllinux_1_2_i686.whl |
|---|---|
| Size | 528.5 kB |
| Tags | CPython 3.8 Linux musl 1.2+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
cf39f72acff6ba2d5f896bc7df2f291d691e606b4277327c3be977b7f68753c9
|
|
BLAKE2b-256 checksum How to use checksums |
16cea0e4d6b467ee8a81a7af5823b2003454a1e3ccfd58ca2e7f5efb700e879b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-musllinux_1_2_armv7l.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 566.1 kB |
| Tags | CPython 3.8 Linux musl 1.2+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
6ad226e626f4ea89d1b2a7ba85ea5d67dcd7515f9a19dfee25fadc7bcf3b0e4b
|
|
BLAKE2b-256 checksum How to use checksums |
b37c2f3ffa0f7ec21d3a71de0b621ea58ffb818a723f0bdd1ab1db778d1ffa01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-musllinux_1_2_aarch64.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 463.7 kB |
| Tags | CPython 3.8 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
36b6cd3f96b1d724a3ce944195a8a0b26bb9b5afad840a51fd3a7cfd582d6e2d
|
|
BLAKE2b-256 checksum How to use checksums |
005e780aa1c46ed6829505edc0f835fe1ffea4f1f0d908cce416a0a09811698b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 292.7 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ed9cbeeb9e003c24b729506814a4c13835d0bf192e2527aa4799a0434e1c7ed2
|
|
BLAKE2b-256 checksum How to use checksums |
43aba4a24e5468d2554e7e1b14038699d57cc6ecc131c65cce777efd00e2d4d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl |
|---|---|
| Size | 315.4 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ IBM System/390x abi3 |
|
SHA-256 checksum How to use checksums |
eaf0eae9bdff13f2bfc747ce1f76d9afde4d2c47bdfe14482baa8eefcc62642a
|
|
BLAKE2b-256 checksum How to use checksums |
5625a4288cc517de363cb6a1903a435edeca78ba587bc4701209fff046dc1085
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 412.0 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
5bf262b2cffcba62e335669db32c4732e1248f9b51b9192ebc4580031aed9640
|
|
BLAKE2b-256 checksum How to use checksums |
83f99c36eb87628430bd52f2fa6947f81d5f76fc222c503217388e7771f6d3b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 290.3 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
e6ccfbf36137ed33a71aec1e439369ccb4385adce4bbc48ada5305d2d5cbb348
|
|
BLAKE2b-256 checksum How to use checksums |
99073f1b1004709bbe151382d418a59900a8ffe6e7c024f7539d76a5a9145196
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 287.7 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
8834068cd2c716aa7935625c96cca88ebc9cb1e186b93d75584514589c12aa7b
|
|
BLAKE2b-256 checksum How to use checksums |
893453ca5bfe7cf46bc21639eddb296643dbcc9d68bf0d958d36adbd1382c5b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl |
|---|---|
| Size | 310.1 kB |
| Tags | CPython 3.8 Linux glibc 2.5+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
7a7b719efc0d6b92469cf85f33a4203ab0a39564150fd11d79bc892e9eac9b93
|
|
BLAKE2b-256 checksum How to use checksums |
3a2c0fe0de418ac45a1826be3d466f837cef0a59334c59df53c3b7d6ac989452
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 256.7 kB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7a80825c7bb93f2be72c5f87b6b1285cc3d839a878480de114e6a46ed0b409d1
|
|
BLAKE2b-256 checksum How to use checksums |
b6e16acfa8d98dea58579e8f7ba66439f5822fe93199357239c6b2c228dcb660
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / python_matchit-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl
| Download URL | python_matchit-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 253.9 kB |
| Tags | CPython 3.8 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
1423906e069f48e32ba5022767c149e7332da0d0de815beac779d2faac9866f0
|
|
BLAKE2b-256 checksum How to use checksums |
68aea2cf34171bda9fa77b5af5c3e51ce2a02f05927ffd29debf611d92070fb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|