]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #28665: Harmonize STORE_DEREF with STORE_FAST and LOAD_DEREF giving a 40% speedup.
authorRaymond Hettinger <python@rcn.com>
Fri, 11 Nov 2016 12:31:18 +0000 (04:31 -0800)
committerRaymond Hettinger <python@rcn.com>
Fri, 11 Nov 2016 12:31:18 +0000 (04:31 -0800)
Misc/NEWS
Python/ceval.c

index cb244f3a352d5f2e1cfc33ba74bbc36e8da492e9..24810f05600bc929dfa22a4e647168fec9edab47 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,8 @@ Core and Builtins
 - Issue #19398: Extra slash no longer added to sys.path components in case of
   empty compile-time PYTHONPATH components.
 
+- Issue #28665:  Improve speed of the STORE_DEREF opcode by 40%.
+
 - Issue #28583: PyDict_SetDefault didn't combine split table when needed.
   Patch by Xiang Zhang.
 
index b2c90cc3b48d4313064df7808113a92f32dfb2fa..6bdc9983e3f0dba88128a80aa03009942111250a 100644 (file)
@@ -2462,8 +2462,9 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
         TARGET(STORE_DEREF) {
             PyObject *v = POP();
             PyObject *cell = freevars[oparg];
-            PyCell_Set(cell, v);
-            Py_DECREF(v);
+            PyObject *oldobj = PyCell_GET(cell);
+            PyCell_SET(cell, v);
+            Py_XDECREF(oldobj);
             DISPATCH();
         }