Documentation: https://aiohttp-fast-url-dispatcher.readthedocs.io
Source Code: https://github.com/bdraco/aiohttp-fast-url-dispatcher
A faster URL dispatcher for aiohttp
The default UrlDispatcher
implementation does a linear search every which can have a significant TimeComplexity when dispatching urls when there are a lot of routes. FastUrlDispatcher
keeps an index of the urls which allows for fast dispatch.
This library will become obsolete with aiohttp 3.10 as the changes are expected to merge upstream via aio-libs/aiohttp#7829
Install this via pip (or your favourite package manager):
pip install aiohttp-fast-url-dispatcher
Attach to a web.Application
before any resources are registered.
dispatcher = FastUrlDispatcher()
app = web.Application()
attach_fast_url_dispatcher(app, dispatcher)
Create with a new web.Application
dispatcher = FastUrlDispatcher()
app = web.Application(router=dispatcher)
If you have multiple handlers that resolve to the same URL, this module will always prefer the static name over a dynamic name. For example:
app.router.add_get(r"/second/{user}/info", handler)
app.router.add_get("/second/bob/info", handler)
"/second/bob/info"
will always be matched before r"/second/{user}/info"
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
This package was created with Copier and the browniebroke/pypackage-template project template.