Replace Py_BuildValue with PyTuple_Pack because it is faster.
Also add a missing DECREF.
This commit is contained in:
parent
e4c03e4520
commit
71dba4ccee
|
@ -2523,7 +2523,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
|
||||||
only it's object list. So we create a tuple, containing
|
only it's object list. So we create a tuple, containing
|
||||||
b_objects list PLUS the array itself, and return that!
|
b_objects list PLUS the array itself, and return that!
|
||||||
*/
|
*/
|
||||||
return Py_BuildValue("(OO)", keep, value);
|
return PyTuple_Pack(2, keep, value);
|
||||||
}
|
}
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"incompatible types, %s instance instead of %s instance",
|
"incompatible types, %s instance instead of %s instance",
|
||||||
|
@ -4228,17 +4228,18 @@ CreateArrayType(PyObject *itemtype, Py_ssize_t length)
|
||||||
PyObject *key;
|
PyObject *key;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
char name[256];
|
char name[256];
|
||||||
|
PyObject *len;
|
||||||
|
|
||||||
if (cache == NULL) {
|
if (cache == NULL) {
|
||||||
cache = PyDict_New();
|
cache = PyDict_New();
|
||||||
if (cache == NULL)
|
if (cache == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#if (PY_VERSION_HEX < 0x02050000)
|
len = PyInt_FromSsize_t(length);
|
||||||
key = Py_BuildValue("(Oi)", itemtype, length);
|
if (len == NULL)
|
||||||
#else
|
return NULL;
|
||||||
key = Py_BuildValue("(On)", itemtype, length);
|
key = PyTuple_Pack(2, itemtype, len);
|
||||||
#endif
|
Py_DECREF(len);
|
||||||
if (!key)
|
if (!key)
|
||||||
return NULL;
|
return NULL;
|
||||||
result = PyDict_GetItemProxy(cache, key);
|
result = PyDict_GetItemProxy(cache, key);
|
||||||
|
@ -4274,8 +4275,10 @@ CreateArrayType(PyObject *itemtype, Py_ssize_t length)
|
||||||
"_type_",
|
"_type_",
|
||||||
itemtype
|
itemtype
|
||||||
);
|
);
|
||||||
if (!result)
|
if (result == NULL) {
|
||||||
|
Py_DECREF(key);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
if (-1 == PyDict_SetItemProxy(cache, key, result)) {
|
if (-1 == PyDict_SetItemProxy(cache, key, result)) {
|
||||||
Py_DECREF(key);
|
Py_DECREF(key);
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
|
|
Loading…
Reference in New Issue