3 ms·
I guess the reason is that it changes the type of the return value. Compare: def moo(): return 5 async def oink(): return 5 moo retur
by skrebbel 11y ago
I guess the reason is that it changes the type of the return value. Compare:
def moo():
return 5
async def oink():
return 5
moo returns 5, oink returns an awaitable.
For a human, without the 'async' marker, you'd have to scan the entire function source to know. I guess also type checkers and documentation tools like to have an idea about the return type.
- Spiritus 11y agoAh right, that makes sense.
- kevin_thibedeau 11y agoThe presence of "yield" also changes the return type. No extra keywords needed for that.