Commit cea87ae3 authored by Stefan Behnel's avatar Stefan Behnel

reduce inlining overhead

parent 7886a373
...@@ -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_anext)) { if (likely(am && am->am_aiter)) {
return (*am->am_anext)(obj); return (*am->am_aiter)(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,9 +558,8 @@ void __Pyx_Coroutine_ExceptionClear(__pyx_CoroutineObject *self) { ...@@ -548,9 +558,8 @@ 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
...@@ -565,41 +574,30 @@ int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) { ...@@ -565,41 +574,30 @@ int __Pyx_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) {
msg = "generator already executing"; msg = "generator already executing";
} }
PyErr_SetString(PyExc_ValueError, msg); PyErr_SetString(PyExc_ValueError, msg);
return 1;
}
return 0;
} }
static CYTHON_INLINE #define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED int closing) { static void __Pyx__Coroutine_NotStartedError(PyObject *gen) {
PyObject *retval;
__Pyx_PyThreadState_declare
assert(!self->is_running);
if (unlikely(self->resume_label == 0)) {
if (unlikely(value && value != Py_None)) {
const char *msg; const char *msg;
if (0) { if (0) {
#ifdef __Pyx_Coroutine_USED #ifdef __Pyx_Coroutine_USED
} else if (__Pyx_Coroutine_CheckExact((PyObject*)self)) { } else if (__Pyx_Coroutine_CheckExact(gen)) {
msg = "can't send non-None value to a just-started coroutine"; msg = "can't send non-None value to a just-started coroutine";
#endif #endif
#ifdef __Pyx_AsyncGen_USED #ifdef __Pyx_AsyncGen_USED
} else if (__Pyx_AsyncGen_CheckExact((PyObject*)self)) { } else if (__Pyx_AsyncGen_CheckExact(gen)) {
msg = "can't send non-None value to a just-started async generator"; msg = "can't send non-None value to a just-started async generator";
#endif #endif
} else { } else {
msg = "can't send non-None value to a just-started generator"; msg = "can't send non-None value to a just-started generator";
} }
PyErr_SetString(PyExc_TypeError, msg); PyErr_SetString(PyExc_TypeError, msg);
return NULL; }
}
}
if (unlikely(self->resume_label == -1)) { #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 #ifdef __Pyx_Coroutine_USED
if (!closing && __Pyx_Coroutine_CheckExact((PyObject*)self)) { if (!closing && __Pyx_Coroutine_CheckExact(gen)) {
// `self` is an exhausted coroutine: raise an error, // `self` is an exhausted coroutine: raise an error,
// except when called from gen_close(), which should // except when called from gen_close(), which should
// always be a silent method. // always be a silent method.
...@@ -610,13 +608,29 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, C ...@@ -610,13 +608,29 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, C
// `gen` is an exhausted generator: // `gen` is an exhausted generator:
// only set exception if called from send(). // only set exception if called from send().
#ifdef __Pyx_AsyncGen_USED #ifdef __Pyx_AsyncGen_USED
if (__Pyx_AsyncGen_CheckExact((PyObject*)self)) if (__Pyx_AsyncGen_CheckExact(gen))
PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
else else
#endif #endif
PyErr_SetNone(PyExc_StopIteration); PyErr_SetNone(PyExc_StopIteration);
} }
return NULL; }
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
PyObject *retval;
__Pyx_PyThreadState_declare
assert(!self->is_running);
if (unlikely(self->resume_label == 0)) {
if (unlikely(value && value != Py_None)) {
return __Pyx_Coroutine_NotStartedError((PyObject*)self);
}
}
if (unlikely(self->resume_label == -1)) {
return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
} }
__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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment