Issue #28665: Harmonize STORE_DEREF with STORE_FAST and LOAD_DEREF giving a 40% speedup.

This commit is contained in:
Raymond Hettinger 2016-11-11 04:31:18 -08:00
parent a27c064428
commit 13527123a1
2 changed files with 5 additions and 2 deletions

View File

@ -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.

View 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();
}