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/.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 python_matchit-0.4.0.tar.gz.
File metadata
- Download URL: python_matchit-0.4.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
783658f44a0459ee0faa6ef84ffc101267d63eea0338cdf517b2d4cf2890f01a
|
|
| MD5 |
ff64968cc36e79792c73ecfea23268a1
|
|
| BLAKE2b-256 |
a3e8ab7c03432f03297d5756feca4aba97cc50c7221881116e422c690ccd653d
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-win_arm64.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-win_arm64.whl
- Upload date:
- Size: 146.5 kB
- Tags: CPython 3.8+, Windows ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
801b8de925f08d5c1ebc2f6b164a68b1cea1268e586d3d48ad3026a109beb7b3
|
|
| MD5 |
1fbf1a5e1c871806fb07ad20c476bd63
|
|
| BLAKE2b-256 |
e0d26b7c7c180e86d168d7dcd1b13b4e09161a9404832f8f700adfc80a28e001
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 149.5 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
099853ca05001af3a12f849bae6a96321c3c9d83e77b17663a0230d9020412db
|
|
| MD5 |
c329ba7609952bb362968a3dc56bf14a
|
|
| BLAKE2b-256 |
0cdacdb2768c79fb6fd7ae0c1c4a48ecb41641a9939225583732b07bb6da6265
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-win32.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-win32.whl
- Upload date:
- Size: 140.0 kB
- Tags: CPython 3.8+, Windows x86
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10a94dcc0d993a437b9d48814e55f2521e97dd7250b97b774f0f611344ec91dd
|
|
| MD5 |
9b8a7c5efe9f10d334f20856cb8ae26f
|
|
| BLAKE2b-256 |
93af27b17e1e8e21a13ffab72aff027a42e3e72cafaa6afce45ae993d909526f
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 496.2 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2f5bef2ae9e4301b65117c96c9b585455e4d687935158622fad128a290c6578
|
|
| MD5 |
a6bbc7e98b0b7256763b84c827a8a58b
|
|
| BLAKE2b-256 |
491f17f4534ca9831dff20f57089e4d0476e3a888968c3b984ea59b22a704c9d
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-musllinux_1_2_i686.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 528.5 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ i686
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf39f72acff6ba2d5f896bc7df2f291d691e606b4277327c3be977b7f68753c9
|
|
| MD5 |
0b0c1c175ef3a02bd4e8279e52fe0095
|
|
| BLAKE2b-256 |
16cea0e4d6b467ee8a81a7af5823b2003454a1e3ccfd58ca2e7f5efb700e879b
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 566.1 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARMv7l
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ad226e626f4ea89d1b2a7ba85ea5d67dcd7515f9a19dfee25fadc7bcf3b0e4b
|
|
| MD5 |
57662498c7340ee7fff2622bfa1ff26e
|
|
| BLAKE2b-256 |
b37c2f3ffa0f7ec21d3a71de0b621ea58ffb818a723f0bdd1ab1db778d1ffa01
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 463.7 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36b6cd3f96b1d724a3ce944195a8a0b26bb9b5afad840a51fd3a7cfd582d6e2d
|
|
| MD5 |
48b1b65dfb30fdb999f16f0ca2d831e5
|
|
| BLAKE2b-256 |
005e780aa1c46ed6829505edc0f835fe1ffea4f1f0d908cce416a0a09811698b
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 292.7 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed9cbeeb9e003c24b729506814a4c13835d0bf192e2527aa4799a0434e1c7ed2
|
|
| MD5 |
a7a1f4527bb8cbf383f04394dd5db4b3
|
|
| BLAKE2b-256 |
43aba4a24e5468d2554e7e1b14038699d57cc6ecc131c65cce777efd00e2d4d6
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 315.4 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ s390x
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaf0eae9bdff13f2bfc747ce1f76d9afde4d2c47bdfe14482baa8eefcc62642a
|
|
| MD5 |
e4338b2eaa8bbd56b4651b577f3f11f3
|
|
| BLAKE2b-256 |
5625a4288cc517de363cb6a1903a435edeca78ba587bc4701209fff046dc1085
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 412.0 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ppc64le
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf262b2cffcba62e335669db32c4732e1248f9b51b9192ebc4580031aed9640
|
|
| MD5 |
2d5873392a0e1e34ebe923f00be233b5
|
|
| BLAKE2b-256 |
83f99c36eb87628430bd52f2fa6947f81d5f76fc222c503217388e7771f6d3b1
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 290.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6ccfbf36137ed33a71aec1e439369ccb4385adce4bbc48ada5305d2d5cbb348
|
|
| MD5 |
ba659f52b31a73ca79e6cf436d4d30e7
|
|
| BLAKE2b-256 |
99073f1b1004709bbe151382d418a59900a8ffe6e7c024f7539d76a5a9145196
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 287.7 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8834068cd2c716aa7935625c96cca88ebc9cb1e186b93d75584514589c12aa7b
|
|
| MD5 |
e8d24458bfdb024eaa8f12af308362b2
|
|
| BLAKE2b-256 |
893453ca5bfe7cf46bc21639eddb296643dbcc9d68bf0d958d36adbd1382c5b3
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 310.1 kB
- Tags: CPython 3.8+, manylinux: glibc 2.5+ i686
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a7b719efc0d6b92469cf85f33a4203ab0a39564150fd11d79bc892e9eac9b93
|
|
| MD5 |
306a56aad37749ae8612027ce8f6e249
|
|
| BLAKE2b-256 |
3a2c0fe0de418ac45a1826be3d466f837cef0a59334c59df53c3b7d6ac989452
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 256.7 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a80825c7bb93f2be72c5f87b6b1285cc3d839a878480de114e6a46ed0b409d1
|
|
| MD5 |
46da53b8859aa86682fa953d1ed41bab
|
|
| BLAKE2b-256 |
b6e16acfa8d98dea58579e8f7ba66439f5822fe93199357239c6b2c228dcb660
|
File details
Details for the file python_matchit-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: python_matchit-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 253.9 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1423906e069f48e32ba5022767c149e7332da0d0de815beac779d2faac9866f0
|
|
| MD5 |
7177475f49de841d919998ebb872bb30
|
|
| BLAKE2b-256 |
68aea2cf34171bda9fa77b5af5c3e51ce2a02f05927ffd29debf611d92070fb7
|