Provide common replacement utils / functions many projects will need
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia esaminando la utility API proposta in questa issue e il ruolo di unasync come strumento di build. L’issue non indica file né test; per procedere sarebbe prima necessario concordare se queste utility debbano appartenere a unasync o a un progetto separato, quindi definire le funzioni supportate, le versioni di Python e il comportamento dei type hint.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- Python
- Stelle
- 108
- Fork
- 16
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-trio/unasync
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
python-trio/unasync#79 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
python-trio/unasync#78 · 1 commento · 1 reazione ·
-
Multitoken substitution Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
python-trio/unasync#74 · 4 commenti · 1 reazione ·
-
JIT Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
python-trio/unasync#72 · 3 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
python-trio/unasync#69 · 1 commento · 1 reazione ·
Tutte le issue di python-trio/unasync
Issue simili
-
bug confirmed issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-webui/open-webui#30750 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100