Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e549c4be
Commit
e549c4be
authored
May 28, 2018
by
jimmylai
Committed by
Yury Selivanov
May 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33505: Optimize asyncio.ensure_future by reordering if conditions (GH-6836)
parent
23f587e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
Lib/asyncio/tasks.py
Lib/asyncio/tasks.py
+5
-5
Misc/NEWS.d/next/Library/2018-05-14-18-05-35.bpo-33505.L8pAyt.rst
...S.d/next/Library/2018-05-14-18-05-35.bpo-33505.L8pAyt.rst
+1
-0
No files found.
Lib/asyncio/tasks.py
View file @
e549c4be
...
...
@@ -542,17 +542,17 @@ def ensure_future(coro_or_future, *, loop=None):
If the argument is a Future, it is returned directly.
"""
if
futures
.
isfuture
(
coro_or_future
):
if
loop
is
not
None
and
loop
is
not
futures
.
_get_loop
(
coro_or_future
):
raise
ValueError
(
'loop argument must agree with Future'
)
return
coro_or_future
elif
coroutines
.
iscoroutine
(
coro_or_future
):
if
coroutines
.
iscoroutine
(
coro_or_future
):
if
loop
is
None
:
loop
=
events
.
get_event_loop
()
task
=
loop
.
create_task
(
coro_or_future
)
if
task
.
_source_traceback
:
del
task
.
_source_traceback
[
-
1
]
return
task
elif
futures
.
isfuture
(
coro_or_future
):
if
loop
is
not
None
and
loop
is
not
futures
.
_get_loop
(
coro_or_future
):
raise
ValueError
(
'loop argument must agree with Future'
)
return
coro_or_future
elif
inspect
.
isawaitable
(
coro_or_future
):
return
ensure_future
(
_wrap_awaitable
(
coro_or_future
),
loop
=
loop
)
else
:
...
...
Misc/NEWS.d/next/Library/2018-05-14-18-05-35.bpo-33505.L8pAyt.rst
0 → 100644
View file @
e549c4be
Optimize asyncio.ensure_future() by reordering if checks: 1.17x faster.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment