File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 33
33
34
34
try :
35
35
_types_coroutine = types .coroutine
36
+ _types_CoroutineType = types .CoroutineType
36
37
except AttributeError :
38
+ # Python 3.4
37
39
_types_coroutine = None
40
+ _types_CoroutineType = None
38
41
39
42
try :
40
43
_inspect_iscoroutinefunction = inspect .iscoroutinefunction
41
44
except AttributeError :
45
+ # Python 3.4
42
46
_inspect_iscoroutinefunction = lambda func : False
43
47
44
48
try :
@@ -255,6 +259,10 @@ def iscoroutinefunction(func):
255
259
_COROUTINE_TYPES = (types .GeneratorType , CoroWrapper )
256
260
if _CoroutineABC is not None :
257
261
_COROUTINE_TYPES += (_CoroutineABC ,)
262
+ if _types_CoroutineType is not None :
263
+ # Prioritize native coroutine check to speed-up
264
+ # asyncio.iscoroutine.
265
+ _COROUTINE_TYPES = (_types_CoroutineType ,) + _COROUTINE_TYPES
258
266
259
267
260
268
def iscoroutine (obj ):
You can’t perform that action at this time.
0 commit comments