summaryrefslogtreecommitdiff
path: root/Cython/Compiler/Nodes.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-10-08 18:59:36 +0200
committerStefan Behnel <stefan_ml@behnel.de>2017-10-08 18:59:36 +0200
commit14b085980903fa5a172a118929aecbae2d1975c4 (patch)
tree3a18a383845bfc3e6ed32749f1a9f869aa86aca6 /Cython/Compiler/Nodes.py
parentdb2d4743c32cb2b43ba984b8b69929bb2c9130a0 (diff)
downloadcython-14b085980903fa5a172a118929aecbae2d1975c4.tar.gz
Speed up some dict lookups in Py3.5+ by calling the faster "_PyDict_GetItem_KnownHash()" instead of "PyDict_GetItem()".
Diffstat (limited to 'Cython/Compiler/Nodes.py')
-rw-r--r--Cython/Compiler/Nodes.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py
index 3e801cdff..3b1595ad2 100644
--- a/Cython/Compiler/Nodes.py
+++ b/Cython/Compiler/Nodes.py
@@ -3830,12 +3830,12 @@ class DefNodeWrapper(FuncDefNode):
continue
code.putln('if (kw_args > 0) {')
# don't overwrite default argument
- code.putln('PyObject* value = PyDict_GetItem(%s, %s);' % (
+ code.putln('PyObject* value = __Pyx_PyDict_GetItemStr(%s, %s);' % (
Naming.kwds_cname, pystring_cname))
code.putln('if (value) { values[%d] = value; kw_args--; }' % i)
code.putln('}')
else:
- code.putln('if (likely((values[%d] = PyDict_GetItem(%s, %s)) != 0)) kw_args--;' % (
+ code.putln('if (likely((values[%d] = __Pyx_PyDict_GetItemStr(%s, %s)) != 0)) kw_args--;' % (
i, Naming.kwds_cname, pystring_cname))
if i < min_positional_args:
if i == 0:
@@ -3921,7 +3921,7 @@ class DefNodeWrapper(FuncDefNode):
else:
code.putln('if (kw_args == 1) {')
code.putln('const Py_ssize_t index = %d;' % first_optional_arg)
- code.putln('PyObject* value = PyDict_GetItem(%s, *%s[index]);' % (
+ code.putln('PyObject* value = __Pyx_PyDict_GetItemStr(%s, *%s[index]);' % (
Naming.kwds_cname, Naming.pykwdlist_cname))
code.putln('if (value) { values[index] = value; kw_args--; }')
if len(optional_args) > 1: