Index: Python/peephole.c =================================================================== --- Python/peephole.c (revision 61058) +++ Python/peephole.c (working copy) @@ -377,6 +377,27 @@ codestr[i+3] = NOP; break; + /* Replace STORE_FAST X/LOAD_FAST X/RETURN_VALUE + with RETURN_VALUE */ + case STORE_FAST: + j = GETARG(codestr, i); + if (codestr[i+3] != LOAD_FAST || + GETARG(codestr, i+3) != j || + !ISBASICBLOCK(blocks,i,5)) + continue; + if (codestr[i+6] == RETURN_VALUE && + ISBASICBLOCK(blocks,i,6)) { + memset(codestr+i, NOP, 6); + } + /* TODO(nnorwitz): if inside a list comp + and there are no other references + to the var (j), we can do the same. + */ + /* TODO(nnorwitz): In some cases we can replace + the STORE/LOAD with DUP_TOP/STORE. + */ + break; + /* Replace LOAD_GLOBAL/LOAD_NAME None with LOAD_CONST None */ case LOAD_NAME: