Sorry for the mild thread necro, searching around and this appears to be the most current thread on the topic ( Decorator to facilitate sync and async calls to one function - #7 by ncoghlan seems similar, but distinct as it’s asking about decorators, and Proposal for a new way to overload methods by arguments, and whether it is synchronous or asynchronous is a proposal)
I read through PEP 492 and a decent amount of the surrounding discussion, but sorry if i missed this having been discussed before - I am wondering why not have a dunder method like __acall__ that is the async counterpart to __call__ , such that for some callable like
class MyCallable:
def __call__():
print('synchronous version')
async def __acall__():
print('async version')
then the await keyword dispatches to an __acall__ if present?
>>> callable = MyCallable()
>>> callable()
'synchronous version'
>>> await callable()
'async version'
it seems like a natural counterpart to __await__?