mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
SF patch #910929: Optimize list comprehensions
Add a new opcode, LIST_APPEND, and apply it to the code generation for list comprehensions. Reduces the per-loop overhead by about a third.
This commit is contained in:
parent
bff63f0343
commit
dd80f76265
6 changed files with 20 additions and 3 deletions
|
@ -1225,6 +1225,15 @@ eval_frame(PyFrameObject *f)
|
|||
if (x != NULL) continue;
|
||||
break;
|
||||
|
||||
case LIST_APPEND:
|
||||
w = POP();
|
||||
v = POP();
|
||||
err = PyList_Append(v, w);
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(w);
|
||||
if (err == 0) continue;
|
||||
break;
|
||||
|
||||
case INPLACE_POWER:
|
||||
w = POP();
|
||||
v = TOP();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue