Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
cea87ae3
Commit
cea87ae3
authored
Aug 08, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce inlining overhead
parent
7886a373
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
79 deletions
+93
-79
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+93
-79
No files found.
Cython/Utility/Coroutine.c
View file @
cea87ae3
...
...
@@ -241,20 +241,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*pro
//@requires: GetAwaitIter
//@requires: ObjectHandling.c::PyObjectCallMethod0
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_GetAsyncIter
(
PyObject
*
obj
)
{
#ifdef __Pyx_AsyncGen_USED
if
(
__Pyx_AsyncGen_CheckExact
(
obj
))
{
return
__Pyx_NewRef
(
obj
);
}
#endif
#if CYTHON_USE_ASYNC_SLOTS
{
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
obj
);
if
(
likely
(
am
&&
am
->
am_aiter
))
{
return
(
*
am
->
am_aiter
)(
obj
);
}
}
#endif
static
PyObject
*
__Pyx_Coroutine_GetAsyncIter_Generic
(
PyObject
*
obj
)
{
#if PY_VERSION_HEX < 0x030500B1
{
PyObject
*
iter
=
__Pyx_PyObject_CallMethod0
(
obj
,
PYIDENT
(
"__aiter__"
));
...
...
@@ -275,20 +262,25 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
}
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_
AsyncIterNext
(
PyObject
*
obj
)
{
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_
GetAsyncIter
(
PyObject
*
obj
)
{
#ifdef __Pyx_AsyncGen_USED
if
(
__Pyx_AsyncGen_CheckExact
(
obj
))
{
return
__Pyx_
async_gen_anext
((
__pyx_PyAsyncGenObject
*
)
obj
);
return
__Pyx_
NewRef
(
obj
);
}
#endif
#if CYTHON_USE_ASYNC_SLOTS
{
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
obj
);
if
(
likely
(
am
&&
am
->
am_a
next
))
{
return
(
*
am
->
am_a
next
)(
obj
);
if
(
likely
(
am
&&
am
->
am_a
iter
))
{
return
(
*
am
->
am_a
iter
)(
obj
);
}
}
#endif
return
__Pyx_Coroutine_GetAsyncIter_Generic
(
obj
);
}
static
PyObject
*
__Pyx__Coroutine_AsyncIterNext
(
PyObject
*
obj
)
{
#if PY_VERSION_HEX < 0x030500B1
{
PyObject
*
value
=
__Pyx_PyObject_CallMethod0
(
obj
,
PYIDENT
(
"__anext__"
));
...
...
@@ -304,6 +296,24 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) {
}
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_AsyncIterNext
(
PyObject
*
obj
)
{
#ifdef __Pyx_AsyncGen_USED
if
(
__Pyx_AsyncGen_CheckExact
(
obj
))
{
return
__Pyx_async_gen_anext
((
__pyx_PyAsyncGenObject
*
)
obj
);
}
#endif
#if CYTHON_USE_ASYNC_SLOTS
{
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
obj
);
if
(
likely
(
am
&&
am
->
am_anext
))
{
return
(
*
am
->
am_anext
)(
obj
);
}
}
#endif
return
__Pyx__Coroutine_AsyncIterNext
(
obj
);
}
//////////////////// pep479.proto ////////////////////
static
void
__Pyx_Generator_Replace_StopIteration
(
int
in_async_gen
);
/*proto*/
...
...
@@ -548,30 +558,66 @@ void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
Py_XDECREF
(
exc_traceback
);
}
static
CYTHON_INLINE
int
__Pyx_Coroutine_CheckRunning
(
__pyx_CoroutineObject
*
gen
)
{
if
(
unlikely
(
gen
->
is_running
))
{
const
char
*
msg
;
if
(
0
)
{
#ifdef __Pyx_Coroutine_USED
}
else
if
(
__Pyx_Coroutine_CheckExact
((
PyObject
*
)
gen
))
{
msg
=
"coroutine already executing"
;
#endif
#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static
void
__Pyx__Coroutine_AlreadyRunningError
(
__pyx_CoroutineObject
*
gen
)
{
const
char
*
msg
;
if
(
0
)
{
#ifdef __Pyx_Coroutine_USED
}
else
if
(
__Pyx_Coroutine_CheckExact
((
PyObject
*
)
gen
))
{
msg
=
"coroutine already executing"
;
#endif
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
((
PyObject
*
)
gen
))
{
msg
=
"async generator already executing"
;
#endif
}
else
{
msg
=
"generator already executing"
;
}
PyErr_SetString
(
PyExc_ValueError
,
msg
);
}
#define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static
void
__Pyx__Coroutine_NotStartedError
(
PyObject
*
gen
)
{
const
char
*
msg
;
if
(
0
)
{
#ifdef __Pyx_Coroutine_USED
}
else
if
(
__Pyx_Coroutine_CheckExact
(
gen
))
{
msg
=
"can't send non-None value to a just-started coroutine"
;
#endif
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
(
gen
))
{
msg
=
"can't send non-None value to a just-started async generator"
;
#endif
}
else
{
msg
=
"can't send non-None value to a just-started generator"
;
}
PyErr_SetString
(
PyExc_TypeError
,
msg
);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static
void
__Pyx__Coroutine_AlreadyTerminatedError
(
PyObject
*
gen
,
PyObject
*
value
,
CYTHON_UNUSED
int
closing
)
{
#ifdef __Pyx_Coroutine_USED
if
(
!
closing
&&
__Pyx_Coroutine_CheckExact
(
gen
))
{
// `self` is an exhausted coroutine: raise an error,
// except when called from gen_close(), which should
// always be a silent method.
PyErr_SetString
(
PyExc_RuntimeError
,
"cannot reuse already awaited coroutine"
);
}
else
#endif
if
(
value
)
{
// `gen` is an exhausted generator:
// only set exception if called from send().
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
((
PyObject
*
)
gen
))
{
msg
=
"async generator already executing"
;
if
(
__Pyx_AsyncGen_CheckExact
(
gen
))
PyErr_SetNone
(
__Pyx_PyExc_StopAsyncIteration
);
else
#endif
}
else
{
msg
=
"generator already executing"
;
}
PyErr_SetString
(
PyExc_ValueError
,
msg
);
return
1
;
PyErr_SetNone
(
PyExc_StopIteration
);
}
return
0
;
}
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_SendEx
(
__pyx_CoroutineObject
*
self
,
PyObject
*
value
,
CYTHON_UNUSED
int
closing
)
{
static
PyObject
*
__Pyx_Coroutine_SendEx
(
__pyx_CoroutineObject
*
self
,
PyObject
*
value
,
int
closing
)
{
PyObject
*
retval
;
__Pyx_PyThreadState_declare
...
...
@@ -579,44 +625,12 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, C
if
(
unlikely
(
self
->
resume_label
==
0
))
{
if
(
unlikely
(
value
&&
value
!=
Py_None
))
{
const
char
*
msg
;
if
(
0
)
{
#ifdef __Pyx_Coroutine_USED
}
else
if
(
__Pyx_Coroutine_CheckExact
((
PyObject
*
)
self
))
{
msg
=
"can't send non-None value to a just-started coroutine"
;
#endif
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
((
PyObject
*
)
self
))
{
msg
=
"can't send non-None value to a just-started async generator"
;
#endif
}
else
{
msg
=
"can't send non-None value to a just-started generator"
;
}
PyErr_SetString
(
PyExc_TypeError
,
msg
);
return
NULL
;
return
__Pyx_Coroutine_NotStartedError
((
PyObject
*
)
self
);
}
}
if
(
unlikely
(
self
->
resume_label
==
-
1
))
{
#ifdef __Pyx_Coroutine_USED
if
(
!
closing
&&
__Pyx_Coroutine_CheckExact
((
PyObject
*
)
self
))
{
// `self` is an exhausted coroutine: raise an error,
// except when called from gen_close(), which should
// always be a silent method.
PyErr_SetString
(
PyExc_RuntimeError
,
"cannot reuse already awaited coroutine"
);
}
else
#endif
if
(
value
)
{
// `gen` is an exhausted generator:
// only set exception if called from send().
#ifdef __Pyx_AsyncGen_USED
if
(
__Pyx_AsyncGen_CheckExact
((
PyObject
*
)
self
))
PyErr_SetNone
(
__Pyx_PyExc_StopAsyncIteration
);
else
#endif
PyErr_SetNone
(
PyExc_StopIteration
);
}
return
NULL
;
return
__Pyx_Coroutine_AlreadyTerminatedError
((
PyObject
*
)
self
,
value
,
closing
);
}
__Pyx_PyThreadState_assign
...
...
@@ -697,8 +711,8 @@ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
PyObject
*
retval
;
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
PyObject
*
yf
=
gen
->
yieldfrom
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)
))
return
NULL
;
if
(
unlikely
(
gen
->
is_running
))
return
__Pyx_Coroutine_AlreadyRunningError
(
gen
)
;
if
(
yf
)
{
PyObject
*
ret
;
// FIXME: does this really need an INCREF() ?
...
...
@@ -786,8 +800,8 @@ static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
static
PyObject
*
__Pyx_Generator_Next
(
PyObject
*
self
)
{
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
PyObject
*
yf
=
gen
->
yieldfrom
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)
))
return
NULL
;
if
(
unlikely
(
gen
->
is_running
))
return
__Pyx_Coroutine_AlreadyRunningError
(
gen
)
;
if
(
yf
)
{
PyObject
*
ret
;
// FIXME: does this really need an INCREF() ?
...
...
@@ -821,8 +835,8 @@ static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
PyObject
*
yf
=
gen
->
yieldfrom
;
int
err
=
0
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)
))
return
NULL
;
if
(
unlikely
(
gen
->
is_running
))
return
__Pyx_Coroutine_AlreadyRunningError
(
gen
)
;
if
(
yf
)
{
Py_INCREF
(
yf
);
...
...
@@ -870,8 +884,8 @@ static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
PyObject
*
yf
=
gen
->
yieldfrom
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)
))
return
NULL
;
if
(
unlikely
(
gen
->
is_running
))
return
__Pyx_Coroutine_AlreadyRunningError
(
gen
)
;
if
(
yf
)
{
PyObject
*
ret
;
...
...
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