From dca6de60d56592b59fa462c4479ad74179baaf33 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 18 Nov 2008 21:06:09 +0100 Subject: [PATCH] use type specific Py*_SetItem() functions --- Cython/Compiler/ExprNodes.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index f9e78cd4..f8a01f36 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1656,8 +1656,15 @@ class IndexNode(ExprNode): index_code = self.index.result() code.globalstate.use_utility_code(setitem_int_utility_code) else: - function = "PyObject_SetItem" index_code = self.index.py_result() + if self.base.type is dict_type: + function = "PyDict_SetItem" + elif self.base.type is list_type: + function = "PyList_SetItem" + elif self.base.type is tuple_type: + function = "PyTuple_SetItem" + else: + function = "PyObject_SetItem" code.putln( "if (%s(%s, %s, %s%s) < 0) %s" % ( function, -- 2.26.2