aiohttp-fast-url-dispatcher
raw JSON → 0.3.1 verified Fri May 01 auth: no python
A faster URL dispatcher for aiohttp web applications. Current version 0.3.1, released July 2024. Replaces aiohttp's built-in URL dispatch with a high-performance alternative. Low release cadence.
pip install aiohttp-fast-url-dispatcher Common errors
error ImportError: cannot import name 'FastUrlDispatcher' from 'aiohttp' ↓
cause Trying to import from aiohttp instead of the separate package.
fix
pip install aiohttp-fast-url-dispatcher and use 'from aiohttp_fast_url_dispatcher import FastUrlDispatcher'
error AttributeError: 'Application' object has no attribute 'router' ↓
cause Trying to set dispatcher before initializing the aiohttp app correctly.
fix
Ensure you create the app with 'web.Application()' and then call 'app.router.set_dispatcher(dispatcher)'
Warnings
deprecated The library requires Python <3.10 and <4.0; support for newer Python versions is limited. v0.3.0 added support for newer Python but check compatibility. ↓
fix Upgrade to v0.3.0+
gotcha FastUrlDispatcher does not support all aiohttp routing features (e.g., nested routers, middlewares on routes). Only use for simple route tables. ↓
fix Ensure your app only uses basic route patterns (plain paths, variable parts). Avoid advanced aiohttp routing features.
gotcha The dispatcher must be set before adding routes; otherwise default dispatcher is used. ↓
fix Call app.router.set_dispatcher(dispatcher) before adding routes, or use dispatcher.add_* methods.
Imports
- FastUrlDispatcher
from aiohttp_fast_url_dispatcher import FastUrlDispatcher
Quickstart
from aiohttp import web
from aiohttp_fast_url_dispatcher import FastUrlDispatcher
app = web.Application()
dispatcher = FastUrlDispatcher()
async def handler(request):
return web.Response(text="Hello, world!")
dispatcher.add_get("/", handler)
app.router.set_dispatcher(dispatcher)
if __name__ == "__main__":
web.run_app(app)