[Python-Dev] LOAD_CONST POP_TOP (original) (raw)
Georg Brandl g.brandl at gmx.net
Fri Jun 30 20:39:13 CEST 2006
- Previous message: [Python-Dev] how long to wait for expat to incorporate a fix to prevent a crasher?
- Next message: [Python-Dev] Python memory model (low level)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 ||
- Previous message: [Python-Dev] how long to wait for expat to incorporate a fix to prevent a crasher?
- Next message: [Python-Dev] Python memory model (low level)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]