--- ../Python-3.2b1/Python/peephole.c 2010-11-30 09:41:01.000000000 +0000 +++ Python/peephole.c 2010-12-08 00:46:30.823334272 +0000 @@ -462,10 +462,10 @@ if (h >= 0 && j <= lastlc && ((opcode == BUILD_TUPLE && - ISBASICBLOCK(blocks, h, 3*(j+1))) || + ISBASICBLOCK(blocks, h, i-h+3)) || ((opcode == BUILD_LIST || opcode == BUILD_SET) && codestr[i+3]==COMPARE_OP && - ISBASICBLOCK(blocks, h, 3*(j+2)) && + ISBASICBLOCK(blocks, h, i-h+6) && (GETARG(codestr,i+3)==6 || GETARG(codestr,i+3)==7))) && tuple_of_constants(&codestr[h], j, consts)) { @@ -477,6 +477,29 @@ !ISBASICBLOCK(blocks,i,6) || j != GETARG(codestr, i+3)) continue; + if(h>=0&&ISBASICBLOCK(blocks, h, i-h+3)){ + for(; h!=i; h+=3) + if(codestr[h]!=LOAD_FAST&& + codestr[h]!=LOAD_GLOBAL&& + codestr[h]!=LOAD_CONST&& + codestr[h]!=LOAD_DEREF&& + codestr[h]!=LOAD_NAME)goto nomemrev1; + h = i-j*3; + j = i; + goto memrev; + } + nomemrev1: + if(ISBASICBLOCK(blocks, i, (j+2)*3)){ + for(h = i+3+j*3; h!=i+3; h-=3) + if(codestr[h]!=STORE_FAST&& + codestr[h]!=STORE_GLOBAL&& + codestr[h]!=STORE_DEREF&& + codestr[h]!=STORE_NAME)goto nomemrev2; + h+= 3; + j = h+j*3; + goto memrev; + } + nomemrev2: if (j == 1) { memset(codestr+i, NOP, 6); } else if (j == 2) { @@ -488,7 +511,15 @@ memset(codestr+i+2, NOP, 4); } break; - + memrev: + for(; h LOAD_CONST binop(c1,c2) */ case BINARY_POWER: --- ../Python-3.2b1/Lib/test/test_peepholer.py 2010-01-19 00:09:57.000000000 +0000 +++ Lib/test/test_peepholer.py 2010-12-08 01:07:20.690000939 +0000 @@ -79,8 +79,8 @@ def test_pack_unpack(self): for line, elem in ( ('a, = a,', 'LOAD_CONST',), - ('a, b = a, b', 'ROT_TWO',), - ('a, b, c = a, b, c', 'ROT_THREE',), + ('a[0], b = a[0], b', 'ROT_TWO',), + ('a[0], b, c = a[0], b, c', 'ROT_THREE',), ): asm = dis_single(line) self.assertIn(elem, asm)