I am not that familiar with asyncio either. I only wrote a few utility scripts that runs concurrent subprocesses mixed with some blocking functions running in concurrent.ProcessPoolExecutor pool (using asyncio.run_in_executor). That is all what I did with regard asyncio. Your function f2 and my function f2 could be actually normal functions. f2 = (x, y) => asyncio.sleep(x + y). f2(3, 7) will just return a coroutine that can be awaited on just fine. To be honest, i don’t even know what the purpose would be with async lambda unless someone with more experience can give us a use case. My guess is that it may be useful to use it as an argument to another async function. Since we can write shortened normal functions (lambda), shortened generator function (lambda with generator expression), people might ask why Python doesn’t have shortened async function? But maybe that is not a good question to begin with? Lambda reminds me of the half life time of isotopes. The other day, I was struggling to teach this to my cousin in elementary school. I just told him to imagine it like def _(args): return something. Assign it to a variable and that variable replaces the underscore. He got it but he found it weird. Sent from my iPhone
On 12 Feb 2021, at 1:41 PM, Paul Moore
wrote: I'm not sure what the use cases would be for an async lambda - the key is that it's not named, so the above isn't a good example as it's just as easy to write
async def f2: return asyncio.sleep(x+y)
(Excuse any errors here, I'm not that familiar with asyncio).