Provide common replacement utils / functions many projects will need
还没有人认领这个 Issue。
评估
调研方向
首先审查此 issue 中提议的 utility API,以及 unasync 作为构建工具所扮演的角色。该 issue 没有指出文件或测试;要开展工作,首先需要确定这些工具应属于 unasync 还是一个独立项目,然后定义支持的函数、Python 版本和类型提示行为。
由索引模型根据 Issue 内容生成。
描述
Some utility functions I was thinking about:
def azip(*iterables): # Convert any iterables and async iterables into a zipped async iterable
iterators = [aiter(x) for x in iterables]
async def generator():
while True:
try:
yield tuple([await x.__anext__() for x in iterators])
except StopAsyncIteration:
break
return generator().__aiter__()
def aiter(x): # Convert any iterable or async iterable into an async iterator
if hasattr(x, "__aiter__"):
return x.__aiter__()
elif hasattr(x, "__anext__"):
return x
async def aiter_wrapper():
for item in x:
yield item
return aiter_wrapper().__aiter__()
async def anext(i): # Advance an async iterator, good for mapping to `next()`
return await i.__anext__()
async def await_or_return(x): # Maps to 'return_()'?
if iscoroutine(x):
return await x
return x
# All of the sync variations of the above functions
next = next
iter = iter
zip = zip
def return_(x):
return x
Could also have azip_longest -> zip_longest, etc.
All of the async functions could be available only on Python 3.6+ so this could be used on projects that support 3.5 or less.
Could also provide type hints that are effected by unasync properly as well.
AsyncOrSyncIterable[X] = Union[AsyncIterable[X], Iterable[X]]
SyncIterable[X] = Iterable[X]
This should probably be a separate project to unasync as unasync is primarily a build tool, raising it here because it'd make sense for the tool to live under python-trio, maybe unasync-utils?
- 主要语言
- Python
- 星标
- 108
- 派生
- 16
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-trio/unasync 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 48/100
python-trio/unasync#79 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 32/100
python-trio/unasync#78 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
python-trio/unasync#74 · 4 条评论 · 1 个 reaction ·
-
JIT未关闭
难度 5/5 一周以上 新手友好度 20/100
python-trio/unasync#72 · 3 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
python-trio/unasync#69 · 1 条评论 · 1 个 reaction ·
查看 python-trio/unasync 的全部 Issue
相似的 Issue
-
area: desktop area: website priority: P2 type: feature
难度 2/5 1-3 小时 新手友好度 62/100
appandflow/stim#3411 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1 小时以内 新手友好度 88/100
baptistehamon/lsapy#185 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
PolicyEngine/policyengine-us#10073 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
syedhamidali/radarx#277 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
Arekkazu/sgpmp-backend#549 ·
维护者通常 1 天内回复