Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b040836

Browse files
committedNov 9, 2016
Improve performance of asyncio.iscoroutine
1 parent ea776a1 commit b040836

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎asyncio/coroutines.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@
3838

3939
try:
4040
_inspect_iscoroutinefunction = inspect.iscoroutinefunction
41+
_inspect_iscoroutine = inspect.iscoroutine
4142
except AttributeError:
43+
# Python 3.4
4244
_inspect_iscoroutinefunction = lambda func: False
45+
_inspect_iscoroutine = lambda obj: False
4346

4447
try:
4548
from collections.abc import Coroutine as _CoroutineABC, \
@@ -259,7 +262,7 @@ def iscoroutinefunction(func):
259262

260263
def iscoroutine(obj):
261264
"""Return True if obj is a coroutine object."""
262-
return isinstance(obj, _COROUTINE_TYPES)
265+
return _inspect_iscoroutine(obj) or isinstance(obj, _COROUTINE_TYPES)
263266

264267

265268
def _format_coroutine(coro):

0 commit comments

Comments
 (0)
This repository has been archived.