Issue 33505: Optimize asyncio.ensure_future by reordering if conditions (original) (raw)
Issue33505
Created on 2018-05-14 20:45 by jimmylai, last changed 2022-04-11 14:59 by admin. This issue is now closed.
Files | |||
---|---|---|---|
File name | Uploaded | Description | Edit |
ensure_future_benchmark.py | jimmylai,2018-05-15 13:41 | ./python.exe ensure_furture_benchmark.py -o ensure_future_optimized.json |
Pull Requests | |||
---|---|---|---|
URL | Status | Linked | Edit |
PR 6832 | closed | jimmylai,2018-05-14 21:18 | |
PR 6836 | merged | jimmylai,2018-05-14 22:07 | |
PR 7162 | merged | miss-islington,2018-05-28 16:43 |
Messages (4) | ||
---|---|---|
msg316572 - (view) | Author: Jimmy Lai (jimmylai) * | Date: 2018-05-14 20:45 |
`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. | ||
msg316656 - (view) | Author: Jimmy Lai (jimmylai) * | Date: 2018-05-15 13:41 |
Benchmark result: ./python.exe -m perf compare_to ensure_future_original.json ensure_future_optimized.json Mean +- std dev: [ensure_future_original] 57.4 ms +- 4.0 ms -> [ensure_future_optimized] 49.3 ms +- 4.5 ms: 1.17x faster (-14%) | ||
msg317887 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2018-05-28 16:42 |
New changeset e549c4be5fb010f5faf12236af8faa720a1429be by Yury Selivanov (jimmylai) in branch 'master': bpo-33505: Optimize asyncio.ensure_future by reordering if conditions (GH-6836) https://github.com/python/cpython/commit/e549c4be5fb010f5faf12236af8faa720a1429be | ||
msg317899 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2018-05-28 18:42 |
New changeset f8fdb368e3d8d048bffc248fbe1023651c276671 by Yury Selivanov (Miss Islington (bot)) in branch '3.7': bpo-33505: Optimize asyncio.ensure_future by reordering if conditions (GH-6836) (#7162) https://github.com/python/cpython/commit/f8fdb368e3d8d048bffc248fbe1023651c276671 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:59:00 | admin | set | github: 77686 |
2018-05-28 19:14:26 | yselivanov | set | status: open -> closedresolution: fixedstage: patch review -> resolved |
2018-05-28 18:42:53 | yselivanov | set | messages: + |
2018-05-28 16:43:33 | miss-islington | set | pull_requests: + <pull%5Frequest6797> |
2018-05-28 16:42:08 | yselivanov | set | messages: + |
2018-05-15 13:41:57 | jimmylai | set | files: + ensure_future_benchmark.pymessages: + |
2018-05-14 22:07:48 | jimmylai | set | pull_requests: + <pull%5Frequest6518> |
2018-05-14 21🔞38 | jimmylai | set | keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest6515> |
2018-05-14 20:45:32 | jimmylai | create |