Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 31618:bc006682acb2 legacy-trunk
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.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Sun, 07 Mar 2004 07:31:06 +0000 |
| parents | fd2103ae6f29 |
| children | b4e4dbd24fe7 |
line wrap: on
line diff
--- a/Python/ceval.c Fri Mar 05 14:33:21 2004 +0000 +++ b/Python/ceval.c Sun Mar 07 07:31:06 2004 +0000 @@ -1225,6 +1225,15 @@ 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();
