1. 10 Eyl, 2010 1 kayıt (commit)
    • Amaury Forgeot d'Arc's avatar
      #4617: Previously it was illegal to delete a name from the local · ba117ef7
      Amaury Forgeot d'Arc yazdı
      namespace if it occurs as a free variable in a nested block.  This limitation
      of the compiler has been lifted, and a new opcode introduced (DELETE_DEREF).
      
      This sample was valid in 2.6, but fails to compile in 3.x without this change::
      
         >>> def f():
         ...     def print_error():
         ...        print(e)
         ...     try:
         ...        something
         ...     except Exception as e:
         ...        print_error()
         ...        # implicit "del e" here
      
      
      This sample has always been invalid in Python, and now works::
      
         >>> def outer(x):
         ...     def inner():
         ...        return x
         ...     inner()
         ...     del x
      
      There is no need to bump the PYC magic number: the new opcode is used
      for code that did not compile before.
      ba117ef7
  2. 04 Eyl, 2010 1 kayıt (commit)
  3. 09 May, 2010 2 kayıt (commit)
  4. 28 Haz, 2009 1 kayıt (commit)
    • Benjamin Peterson's avatar
      Merged revisions 72912,72920,72940 via svnmerge from · 876b2f28
      Benjamin Peterson yazdı
      svn+ssh://pythondev@svn.python.org/python/trunk
      
      ........
        r72912 | benjamin.peterson | 2009-05-25 08:13:44 -0500 (Mon, 25 May 2009) | 5 lines
      
        add a SETUP_WITH opcode
      
        It speeds up the with statement and correctly looks up the special
        methods involved.
      ........
        r72920 | benjamin.peterson | 2009-05-25 15:12:57 -0500 (Mon, 25 May 2009) | 1 line
      
        take into account the fact that SETUP_WITH pushes a finally block
      ........
        r72940 | benjamin.peterson | 2009-05-26 07:49:59 -0500 (Tue, 26 May 2009) | 1 line
      
        teach the peepholer about SETUP_WITH
      ........
      876b2f28
  5. 25 Şub, 2009 1 kayıt (commit)
    • Jeffrey Yasskin's avatar
      http://bugs.python.org/issue4715 · 9de7ec78
      Jeffrey Yasskin yazdı
      This patch by Antoine Pitrou optimizes the bytecode for conditional branches by
      merging the following "POP_TOP" instruction into the conditional jump.  For
      example, the list comprehension "[x for x in l if not x]" produced the
      following bytecode:
      
        1           0 BUILD_LIST               0
                    3 LOAD_FAST                0 (.0)
              >>    6 FOR_ITER                23 (to 32)
                    9 STORE_FAST               1 (x)
                   12 LOAD_FAST                1 (x)
                   15 JUMP_IF_TRUE            10 (to 28)
                   18 POP_TOP
                   19 LOAD_FAST                1 (x)
                   22 LIST_APPEND              2
                   25 JUMP_ABSOLUTE            6
              >>   28 POP_TOP
                   29 JUMP_ABSOLUTE            6
              >>   32 RETURN_VALUE
      
      but after the patch it produces the following bytecode:
      
        1           0 BUILD_LIST               0
                    3 LOAD_FAST                0 (.0)
              >>    6 FOR_ITER                18 (to 27)
                    9 STORE_FAST               1 (x)
                   12 LOAD_FAST                1 (x)
                   15 POP_JUMP_IF_TRUE         6
                   18 LOAD_FAST                1 (x)
                   21 LIST_APPEND              2
                   24 JUMP_ABSOLUTE            6
              >>   27 RETURN_VALUE
      
      Notice that not only the code is shorter, but the conditional jump
      (POP_JUMP_IF_TRUE) jumps right to the start of the loop instead of going through
      the JUMP_ABSOLUTE at the end. "continue" statements are helped
      similarly.
      
      Furthermore, the old jump opcodes (JUMP_IF_FALSE, JUMP_IF_TRUE) have been
      replaced by two new opcodes:
      - JUMP_IF_TRUE_OR_POP, which jumps if true and pops otherwise
      - JUMP_IF_FALSE_OR_POP, which jumps if false and pops otherwise
      9de7ec78
  6. 25 Ock, 2009 1 kayıt (commit)