Commit 23350e5a authored by Stefan Behnel's avatar Stefan Behnel

move __Pyx_GetName() into external utility file and make it use faster __Pyx_PyObject_GetAttrStr()

parent 10596f28
......@@ -10229,33 +10229,13 @@ class DocstringRefNode(ExprNode):
code.put_gotref(self.result())
#------------------------------------------------------------------------------------
#
# Runtime support code
#
#------------------------------------------------------------------------------------
get_name_interned_utility_code = UtilityCode(
proto = """
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
""",
impl = """
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
PyObject *result;
result = PyObject_GetAttr(dict, name);
if (!result) {
if (dict != %(BUILTINS)s) {
PyErr_Clear();
result = PyObject_GetAttr(%(BUILTINS)s, name);
}
if (!result) {
PyErr_SetObject(PyExc_NameError, name);
}
}
return result;
}
""" % {'BUILTINS' : Naming.builtins_cname})
get_name_interned_utility_code = UtilityCode.load("GetGlobalName", "ObjectHandling.c")
#------------------------------------------------------------------------------------
......
......@@ -586,6 +586,29 @@ static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}
/////////////// GetGlobalName.proto ///////////////
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
/////////////// GetGlobalName ///////////////
//@requires: PyObjectGetAttrStr
//@substitute: naming
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
PyObject *result;
result = __Pyx_PyObject_GetAttrStr(dict, name);
if (!result) {
if (dict != $builtins_cname) {
PyErr_Clear();
result = __Pyx_PyObject_GetAttrStr($builtins_cname, name);
}
if (!result) {
PyErr_SetObject(PyExc_NameError, name);
}
}
return result;
}
/////////////// PyObjectGetAttrStr.proto ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
......
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