Commit a3cfec8f authored by Stefan Behnel's avatar Stefan Behnel

use fast PyFunction calls in some more places

parent 8f3d3bd1
...@@ -1258,6 +1258,7 @@ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name ...@@ -1258,6 +1258,7 @@ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name
/////////////// PyObjectCallMethod1 /////////////// /////////////// PyObjectCallMethod1 ///////////////
//@requires: PyObjectGetAttrStr //@requires: PyObjectGetAttrStr
//@requires: PyObjectCallOneArg //@requires: PyObjectCallOneArg
//@requires: PyFunctionFastCall
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
PyObject *method, *result = NULL; PyObject *method, *result = NULL;
...@@ -1269,6 +1270,13 @@ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name ...@@ -1269,6 +1270,13 @@ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name
if (likely(self)) { if (likely(self)) {
PyObject *args; PyObject *args;
PyObject *function = PyMethod_GET_FUNCTION(method); PyObject *function = PyMethod_GET_FUNCTION(method);
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(function)) {
PyObject *args[2] = {self, arg};
result = __Pyx_PyFunction_FastCall(function, args, 2, NULL);
goto done;
}
#endif
args = PyTuple_New(2); args = PyTuple_New(2);
if (unlikely(!args)) goto bad; if (unlikely(!args)) goto bad;
Py_INCREF(self); Py_INCREF(self);
...@@ -1285,6 +1293,7 @@ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name ...@@ -1285,6 +1293,7 @@ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name
} }
#endif #endif
result = __Pyx_PyObject_CallOneArg(method, arg); result = __Pyx_PyObject_CallOneArg(method, arg);
done:
bad: bad:
Py_XDECREF(method); Py_XDECREF(method);
return result; return result;
...@@ -1298,15 +1307,24 @@ static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name ...@@ -1298,15 +1307,24 @@ static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name
/////////////// PyObjectCallMethod2 /////////////// /////////////// PyObjectCallMethod2 ///////////////
//@requires: PyObjectGetAttrStr //@requires: PyObjectGetAttrStr
//@requires: PyObjectCall //@requires: PyObjectCall
//@requires: PyFunctionFastCall
static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name, PyObject* arg1, PyObject* arg2) { static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name, PyObject* arg1, PyObject* arg2) {
PyObject *args, *method, *result = NULL; PyObject *args, *method, *result = NULL;
method = __Pyx_PyObject_GetAttrStr(obj, method_name); method = __Pyx_PyObject_GetAttrStr(obj, method_name);
if (unlikely(!method)) return NULL;
#if CYTHON_UNPACK_METHODS #if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(method)) && likely(PyMethod_GET_SELF(method))) { if (likely(PyMethod_Check(method)) && likely(PyMethod_GET_SELF(method))) {
PyObject *self, *function; PyObject *self, *function;
self = PyMethod_GET_SELF(method); self = PyMethod_GET_SELF(method);
function = PyMethod_GET_FUNCTION(method); function = PyMethod_GET_FUNCTION(method);
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(function)) {
PyObject *args[3] = {self, arg1, arg2};
result = __Pyx_PyFunction_FastCall(function, args, 3, NULL);
goto done;
}
#endif
args = PyTuple_New(3); args = PyTuple_New(3);
if (unlikely(!args)) goto bad; if (unlikely(!args)) goto bad;
Py_INCREF(self); Py_INCREF(self);
...@@ -1319,6 +1337,13 @@ static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name ...@@ -1319,6 +1337,13 @@ static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name
Py_DECREF(method); Py_DECREF(method);
method = function; method = function;
} else } else
#endif
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(method)) {
PyObject *args[2] = {arg1, arg2};
result = __Pyx_PyFunction_FastCall(method, args, 2, NULL);
goto done;
} else
#endif #endif
{ {
args = PyTuple_New(2); args = PyTuple_New(2);
...@@ -1330,10 +1355,9 @@ static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name ...@@ -1330,10 +1355,9 @@ static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name
} }
result = __Pyx_PyObject_Call(method, args, NULL); result = __Pyx_PyObject_Call(method, args, NULL);
Py_DECREF(args); Py_DECREF(args);
Py_DECREF(method); done:
return result;
bad: bad:
Py_XDECREF(method); Py_DECREF(method);
return result; return result;
} }
...@@ -1628,6 +1652,7 @@ static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y); ...@@ -1628,6 +1652,7 @@ static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y);
/////////////// MatrixMultiply /////////////// /////////////// MatrixMultiply ///////////////
//@requires: PyObjectGetAttrStr //@requires: PyObjectGetAttrStr
//@requires: PyObjectCallOneArg //@requires: PyObjectCallOneArg
//@requires: PyFunctionFastCall
#if PY_VERSION_HEX < 0x03050000 #if PY_VERSION_HEX < 0x03050000
static PyObject* __Pyx_PyObject_CallMatrixMethod(PyObject* method, PyObject* arg) { static PyObject* __Pyx_PyObject_CallMatrixMethod(PyObject* method, PyObject* arg) {
...@@ -1639,6 +1664,13 @@ static PyObject* __Pyx_PyObject_CallMatrixMethod(PyObject* method, PyObject* arg ...@@ -1639,6 +1664,13 @@ static PyObject* __Pyx_PyObject_CallMatrixMethod(PyObject* method, PyObject* arg
if (likely(self)) { if (likely(self)) {
PyObject *args; PyObject *args;
PyObject *function = PyMethod_GET_FUNCTION(method); PyObject *function = PyMethod_GET_FUNCTION(method);
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(function)) {
PyObject *args[2] = {self, arg};
result = __Pyx_PyFunction_FastCall(function, args, 2, NULL);
goto done;
}
#endif
args = PyTuple_New(2); args = PyTuple_New(2);
if (unlikely(!args)) goto bad; if (unlikely(!args)) goto bad;
Py_INCREF(self); Py_INCREF(self);
...@@ -1655,6 +1687,7 @@ static PyObject* __Pyx_PyObject_CallMatrixMethod(PyObject* method, PyObject* arg ...@@ -1655,6 +1687,7 @@ static PyObject* __Pyx_PyObject_CallMatrixMethod(PyObject* method, PyObject* arg
} }
#endif #endif
result = __Pyx_PyObject_CallOneArg(method, arg); result = __Pyx_PyObject_CallOneArg(method, arg);
done:
bad: bad:
Py_DECREF(method); Py_DECREF(method);
return result; return result;
......
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