changeset: 105056:d78d45436753 branch: 3.6 parent: 105053:1a88baaed7a0 user: Raymond Hettinger date: Fri Nov 11 04:31:18 2016 -0800 files: Misc/NEWS Python/ceval.c description: Issue #28665: Harmonize STORE_DEREF with STORE_FAST and LOAD_DEREF giving a 40% speedup. diff -r 1a88baaed7a0 -r d78d45436753 Misc/NEWS --- a/Misc/NEWS Fri Nov 11 12:06:38 2016 +0200 +++ b/Misc/NEWS Fri Nov 11 04:31:18 2016 -0800 @@ -13,6 +13,8 @@ - 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. diff -r 1a88baaed7a0 -r d78d45436753 Python/ceval.c --- a/Python/ceval.c Fri Nov 11 12:06:38 2016 +0200 +++ b/Python/ceval.c Fri Nov 11 04:31:18 2016 -0800 @@ -2462,8 +2462,9 @@ 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(); }