Hi, the following patch tries to fix the LOAD_CONST POP_TOP optimization lost in 2.5 (bug #1333982).
An example for this is: def f(): 'a' # docstring 'b' Georg PS: Hmm. While looking, I see that 2.4 doesn't optimize away other constants like def g(): 1 Index: Python/compile.c =================================================================== --- Python/compile.c (Revision 47150) +++ Python/compile.c (Arbeitskopie) @@ -775,10 +775,16 @@ } break; + case LOAD_CONST: + cumlc = lastlc + 1; + /* Skip over LOAD_CONST POP_TOP */ + if (codestr[i+3] == POP_TOP) { + memset(codestr+i, NOP, 4); + cumlc = 0; + break; + } /* Skip over LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP */ - case LOAD_CONST: - cumlc = lastlc + 1; j = GETARG(codestr, i); if (codestr[i+3] != JUMP_IF_FALSE || codestr[i+6] != POP_TOP || _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com