New submission from Jimmy Lai <yuri...@gmail.com>: `ensure_future` converts the input as future if it's not already a future. The condition is the following:
if futures.isfuture(coro_or_future): ... elif coroutines.iscoroutine(coro_or_future): ... elif inspect.isawaitable(coro_or_future): ... In real world, `ensure_future` is mostly called by `run_until_complete` and gather with async function call (coroutine) as input. We should check `iscoroutine` first to make it most efficient. ---------- components: asyncio messages: 316572 nosy: asvetlov, jimmylai, yselivanov priority: normal severity: normal status: open title: Optimize asyncio.ensure_future by reordering if conditions type: performance versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33505> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com