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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
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
...
@@ -241,20 +241,7 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o); /*pro
//@requires: GetAwaitIter
//@requires: GetAwaitIter
//@requires: ObjectHandling.c::PyObjectCallMethod0
//@requires: ObjectHandling.c::PyObjectCallMethod0
static
CYTHON_INLINE
PyObject
*
__Pyx_Coroutine_GetAsyncIter
(
PyObject
*
obj
)
{
static
PyObject
*
__Pyx_Coroutine_GetAsyncIter_Generic
(
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
#if PY_VERSION_HEX < 0x030500B1
#if PY_VERSION_HEX < 0x030500B1
{
{
PyObject
*
iter
=
__Pyx_PyObject_CallMethod0
(
obj
,
PYIDENT
(
"__aiter__"
));
PyObject
*
iter
=
__Pyx_PyObject_CallMethod0
(
obj
,
PYIDENT
(
"__aiter__"
));
...
@@ -275,20 +262,25 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
...
@@ -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
#ifdef __Pyx_AsyncGen_USED
if
(
__Pyx_AsyncGen_CheckExact
(
obj
))
{
if
(
__Pyx_AsyncGen_CheckExact
(
obj
))
{
return
__Pyx_
async_gen_anext
((
__pyx_PyAsyncGenObject
*
)
obj
);
return
__Pyx_
NewRef
(
obj
);
}
}
#endif
#endif
#if CYTHON_USE_ASYNC_SLOTS
#if CYTHON_USE_ASYNC_SLOTS
{
{
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
obj
);
__Pyx_PyAsyncMethodsStruct
*
am
=
__Pyx_PyType_AsAsync
(
obj
);
if
(
likely
(
am
&&
am
->
am_a
next
))
{
if
(
likely
(
am
&&
am
->
am_a
iter
))
{
return
(
*
am
->
am_a
next
)(
obj
);
return
(
*
am
->
am_a
iter
)(
obj
);
}
}
}
}
#endif
#endif
return
__Pyx_Coroutine_GetAsyncIter_Generic
(
obj
);
}
static
PyObject
*
__Pyx__Coroutine_AsyncIterNext
(
PyObject
*
obj
)
{
#if PY_VERSION_HEX < 0x030500B1
#if PY_VERSION_HEX < 0x030500B1
{
{
PyObject
*
value
=
__Pyx_PyObject_CallMethod0
(
obj
,
PYIDENT
(
"__anext__"
));
PyObject
*
value
=
__Pyx_PyObject_CallMethod0
(
obj
,
PYIDENT
(
"__anext__"
));
...
@@ -304,6 +296,24 @@ static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) {
...
@@ -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 ////////////////////
//////////////////// pep479.proto ////////////////////
static
void
__Pyx_Generator_Replace_StopIteration
(
int
in_async_gen
);
/*proto*/
static
void
__Pyx_Generator_Replace_StopIteration
(
int
in_async_gen
);
/*proto*/
...
@@ -548,30 +558,66 @@ void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
...
@@ -548,30 +558,66 @@ void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) {
Py_XDECREF
(
exc_traceback
);
Py_XDECREF
(
exc_traceback
);
}
}
static
CYTHON_INLINE
#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
int
__Pyx_Coroutine_CheckRunning
(
__pyx_CoroutineObject
*
gen
)
{
static
void
__Pyx__Coroutine_AlreadyRunningError
(
__pyx_CoroutineObject
*
gen
)
{
if
(
unlikely
(
gen
->
is_running
))
{
const
char
*
msg
;
const
char
*
msg
;
if
(
0
)
{
if
(
0
)
{
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Coroutine_USED
}
else
if
(
__Pyx_Coroutine_CheckExact
((
PyObject
*
)
gen
))
{
}
else
if
(
__Pyx_Coroutine_CheckExact
((
PyObject
*
)
gen
))
{
msg
=
"coroutine already executing"
;
msg
=
"coroutine already executing"
;
#endif
#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
#ifdef __Pyx_AsyncGen_USED
}
else
if
(
__Pyx_AsyncGen_CheckExact
((
PyObject
*
)
gen
))
{
if
(
__Pyx_AsyncGen_CheckExact
(
gen
))
msg
=
"async generator already executing"
;
PyErr_SetNone
(
__Pyx_PyExc_StopAsyncIteration
);
else
#endif
#endif
}
else
{
PyErr_SetNone
(
PyExc_StopIteration
);
msg
=
"generator already executing"
;
}
PyErr_SetString
(
PyExc_ValueError
,
msg
);
return
1
;
}
}
return
0
;
}
}
static
CYTHON_INLINE
static
PyObject
*
__Pyx_Coroutine_SendEx
(
__pyx_CoroutineObject
*
self
,
PyObject
*
value
,
CYTHON_UNUSED
int
closing
)
{
PyObject
*
__Pyx_Coroutine_SendEx
(
__pyx_CoroutineObject
*
self
,
PyObject
*
value
,
int
closing
)
{
PyObject
*
retval
;
PyObject
*
retval
;
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_declare
...
@@ -579,44 +625,12 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, C
...
@@ -579,44 +625,12 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, C
if
(
unlikely
(
self
->
resume_label
==
0
))
{
if
(
unlikely
(
self
->
resume_label
==
0
))
{
if
(
unlikely
(
value
&&
value
!=
Py_None
))
{
if
(
unlikely
(
value
&&
value
!=
Py_None
))
{
const
char
*
msg
;
return
__Pyx_Coroutine_NotStartedError
((
PyObject
*
)
self
);
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
;
}
}
}
}
if
(
unlikely
(
self
->
resume_label
==
-
1
))
{
if
(
unlikely
(
self
->
resume_label
==
-
1
))
{
#ifdef __Pyx_Coroutine_USED
return
__Pyx_Coroutine_AlreadyTerminatedError
((
PyObject
*
)
self
,
value
,
closing
);
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
;
}
}
__Pyx_PyThreadState_assign
__Pyx_PyThreadState_assign
...
@@ -697,8 +711,8 @@ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
...
@@ -697,8 +711,8 @@ static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
PyObject
*
retval
;
PyObject
*
retval
;
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
PyObject
*
yf
=
gen
->
yieldfrom
;
PyObject
*
yf
=
gen
->
yieldfrom
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)
))
if
(
unlikely
(
gen
->
is_running
))
return
NULL
;
return
__Pyx_Coroutine_AlreadyRunningError
(
gen
)
;
if
(
yf
)
{
if
(
yf
)
{
PyObject
*
ret
;
PyObject
*
ret
;
// FIXME: does this really need an INCREF() ?
// FIXME: does this really need an INCREF() ?
...
@@ -786,8 +800,8 @@ static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
...
@@ -786,8 +800,8 @@ static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
static
PyObject
*
__Pyx_Generator_Next
(
PyObject
*
self
)
{
static
PyObject
*
__Pyx_Generator_Next
(
PyObject
*
self
)
{
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
PyObject
*
yf
=
gen
->
yieldfrom
;
PyObject
*
yf
=
gen
->
yieldfrom
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)
))
if
(
unlikely
(
gen
->
is_running
))
return
NULL
;
return
__Pyx_Coroutine_AlreadyRunningError
(
gen
)
;
if
(
yf
)
{
if
(
yf
)
{
PyObject
*
ret
;
PyObject
*
ret
;
// FIXME: does this really need an INCREF() ?
// FIXME: does this really need an INCREF() ?
...
@@ -821,8 +835,8 @@ static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
...
@@ -821,8 +835,8 @@ static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
PyObject
*
yf
=
gen
->
yieldfrom
;
PyObject
*
yf
=
gen
->
yieldfrom
;
int
err
=
0
;
int
err
=
0
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)
))
if
(
unlikely
(
gen
->
is_running
))
return
NULL
;
return
__Pyx_Coroutine_AlreadyRunningError
(
gen
)
;
if
(
yf
)
{
if
(
yf
)
{
Py_INCREF
(
yf
);
Py_INCREF
(
yf
);
...
@@ -870,8 +884,8 @@ static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject
...
@@ -870,8 +884,8 @@ static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
__pyx_CoroutineObject
*
gen
=
(
__pyx_CoroutineObject
*
)
self
;
PyObject
*
yf
=
gen
->
yieldfrom
;
PyObject
*
yf
=
gen
->
yieldfrom
;
if
(
unlikely
(
__Pyx_Coroutine_CheckRunning
(
gen
)
))
if
(
unlikely
(
gen
->
is_running
))
return
NULL
;
return
__Pyx_Coroutine_AlreadyRunningError
(
gen
)
;
if
(
yf
)
{
if
(
yf
)
{
PyObject
*
ret
;
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