跳转到主要内容

为aiohttp提供更快的URL分发器

项目描述

aiohttp-fast-url-dispatcher

CI Status Documentation Status Test coverage percentage

Poetry black pre-commit

PyPI Version Supported Python versions License


文档: https://aiohttp-fast-url-dispatcher.readthedocs.io

源代码: https://github.com/bdraco/aiohttp-fast-url-dispatcher


为aiohttp提供更快的URL分发器

默认的 UrlDispatcher 实现会进行线性搜索,当有很多路由时,这可能会导致显著的 时间复杂度FastUrlDispatcher 会保留url索引,允许快速分发。

随着aiohttp 3.10的发布,这个库将会变得过时,因为这些更改预计将通过 https://github.com/aio-libs/aiohttp/pull/7829 合并到上游。

安装

使用pip(或您喜欢的包管理器)安装此软件包。

pip install aiohttp-fast-url-dispatcher

使用

在注册任何资源之前,将其附加到 web.Application 上。

dispatcher = FastUrlDispatcher()
app = web.Application()
attach_fast_url_dispatcher(app, dispatcher)

使用新的 web.Application 创建。

dispatcher = FastUrlDispatcher()
app = web.Application(router=dispatcher)

注意事项

如果您有多个处理程序解析到相同的URL,此模块将始终优先选择静态名称而不是动态名称。例如

app.router.add_get(r"/second/{user}/info", handler)
app.router.add_get("/second/bob/info", handler)

"/second/bob/info" 总是在 r"/second/{user}/info" 之前匹配

贡献者 ✨

感谢这些可爱的人们 (emoji key)

本项目遵循all-contributors规范。欢迎所有类型的贡献!

致谢

此软件包使用Copierbrowniebroke/pypackage-template项目模板创建。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装软件包的更多信息。

源代码分发

aiohttp_fast_url_dispatcher-0.3.1.tar.gz (9.1 kB 查看散列)

上传时间 源代码

构建分发

aiohttp_fast_url_dispatcher-0.3.1-py3-none-any.whl (8.9 kB 查看散列)

上传时间 Python 3

支持