Skip to main content

A faster URL dispatcher for aiohttp

Project description

aiohttp-fast-url-dispatcher

CI Status Documentation Status Test coverage percentage

Poetry black pre-commit

PyPI Version Supported Python versions License


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 https://github.com/aio-libs/aiohttp/pull/7829

Installation

Install this via pip (or your favourite package manager):

pip install aiohttp-fast-url-dispatcher

Usage

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)

Caveats

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"

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

This package was created with Copier and the browniebroke/pypackage-template project template.

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

aiohttp_fast_url_dispatcher-0.3.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file aiohttp_fast_url_dispatcher-0.3.0.tar.gz.

File metadata

  • Download URL: aiohttp_fast_url_dispatcher-0.3.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/35.0 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.12.0 keyring/23.13.1 rfc3986/1.5.0 colorama/0.4.6 CPython/3.10.13

File hashes

Hashes for aiohttp_fast_url_dispatcher-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0fc11c60a4209429340d9d2d07b6b0819a45ebd0d47ceb78bea915dbe042addd
MD5 22d88caadce27304168bbd0238fbb0d2
BLAKE2b-256 78e8ad774b006fc21425ee29708de0f58696d8f1f5a9a9ce1f744e72ee8b4bfd

See more details on using hashes here.

File details

Details for the file aiohttp_fast_url_dispatcher-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: aiohttp_fast_url_dispatcher-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/35.0 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.12.0 keyring/23.13.1 rfc3986/1.5.0 colorama/0.4.6 CPython/3.10.13

File hashes

Hashes for aiohttp_fast_url_dispatcher-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e038458a34b79ef7c276b3257a1cdc73625da92cf4b64c2d0aefc4fe04dcdbbb
MD5 064b78a142a086d09c5cd191cdba4a87
BLAKE2b-256 1d909042a3a566903fbc65396058dcd4fa5b04929cc748d3e3754ae06b4957c5

See more details on using hashes here.

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