Message371501
context managers and except blocks generates multiple POP_TOPS constantly and maybe other cases which might lead generation of multiple POP_TOPS. A SHRINK_STACK(n) opcode would make things better (improvement on pyc size, less opcodes = faster evaluation).
A possible patch:
(to peephole.c)
+
+ case POP_TOP:
+ h = i + 1;
+ while (h < codelen && _Py_OPCODE(codestr[h]) == POP_TOP) {
+ h++;
+ }
+ if (h > i + 1) {
+ codestr[i] = PACKOPARG(SHRINK_STACK, h - i);
+ fill_nops(codestr, i + 1, h);
+ nexti = h;
+ }
+ break;
(to ceval.c)
+ case TARGET(SHRINK_STACK): {
+ for (int i = 0; i < oparg; i++) {
+ PyObject *value = POP();
+ Py_DECREF(value);
+ }
+ FAST_DISPATCH();
+ }
+
and some other minor things for opcode.py and magic number |
|
Date |
User |
Action |
Args |
2020-06-14 12:08:18 | shrink_stack | set | recipients:
+ shrink_stack |
2020-06-14 12:08:18 | shrink_stack | set | messageid: <1592136498.04.0.523354391069.issue40974@roundup.psfhosted.org> |
2020-06-14 12:08:18 | shrink_stack | link | issue40974 messages |
2020-06-14 12:08:17 | shrink_stack | create | |
|