Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1352712

Browse files
committed
Issue #28665: Harmonize STORE_DEREF with STORE_FAST and LOAD_DEREF giving a 40% speedup.
1 parent a27c064 commit 1352712

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Core and Builtins
1313
- Issue #19398: Extra slash no longer added to sys.path components in case of
1414
empty compile-time PYTHONPATH components.
1515

16+
- Issue #28665: Improve speed of the STORE_DEREF opcode by 40%.
17+
1618
- Issue #28583: PyDict_SetDefault didn't combine split table when needed.
1719
Patch by Xiang Zhang.
1820

Python/ceval.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,8 +2462,9 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
24622462
TARGET(STORE_DEREF) {
24632463
PyObject *v = POP();
24642464
PyObject *cell = freevars[oparg];
2465-
PyCell_Set(cell, v);
2466-
Py_DECREF(v);
2465+
PyObject *oldobj = PyCell_GET(cell);
2466+
PyCell_SET(cell, v);
2467+
Py_XDECREF(oldobj);
24672468
DISPATCH();
24682469
}
24692470

0 commit comments

Comments
 (0)