summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-02-09 04:34:49 (GMT)
committerRaymond Hettinger <python@rcn.com>2016-02-09 04:34:49 (GMT)
commit38418662e0339b6331e0c7e00ea55f41b28bf38d (patch)
tree7ac6f3257b7157d6f281f33366562020d5e4e6ff /Modules/_collectionsmodule.c
parent263c448a2e57378aee775e9a994ab87946233160 (diff)
downloadcpython-38418662e0339b6331e0c7e00ea55f41b28bf38d.zip
cpython-38418662e0339b6331e0c7e00ea55f41b28bf38d.tar.gz
cpython-38418662e0339b6331e0c7e00ea55f41b28bf38d.tar.bz2
Issue #26200: The SETREF macro adds unnecessary work in some cases.
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 479b052..0b7a88f 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1218,6 +1218,7 @@ deque_del_item(dequeobject *deque, Py_ssize_t i)
static int
deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
{
+ PyObject *old_value;
block *b;
Py_ssize_t n, len=Py_SIZE(deque), halflen=(len+1)>>1, index=i;
@@ -1246,7 +1247,9 @@ deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
b = b->leftlink;
}
Py_INCREF(v);
- Py_SETREF(b->data[i], v);
+ old_value = b->data[i];
+ b->data[i] = v;
+ Py_DECREF(old_value);
return 0;
}