This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author abbeyj
Recipients abbeyj, collinwinter, jyasskin, pitrou, rhettinger
Date 2009-06-15.19:08:27
SpamBayes Score 7.4437216e-05
Marked as misclassified No
Message-id <1245092908.94.0.917434465219.issue6250@psf.upfronthosting.co.za>
In-reply-to
Content
I should add that the patch doesn't only address dead user-code.  It
also eliminates code that the compiler generates itself but that would
be unreachable at runtime.  Consider the following function:

def foo(x):
  if x:
    raise Something
  else:
    raise SomethingElse


Without the patch this would compile to:
  2           0 LOAD_FAST                0 (x)
              3 POP_JUMP_IF_FALSE       15

  3           6 LOAD_GLOBAL              0 (Something)
              9 RAISE_VARARGS            1
             12 JUMP_FORWARD             6 (to 21)

  5     >>   15 LOAD_GLOBAL              1 (SomethingElse)
             18 RAISE_VARARGS            1
        >>   21 LOAD_CONST               0 (None)
             24 RETURN_VALUE


With the patch this slims down to:

  2           0 LOAD_FAST                0 (x)
              3 POP_JUMP_IF_FALSE       12

  3           6 LOAD_GLOBAL              0 (Something)
              9 RAISE_VARARGS            1

  5     >>   12 LOAD_GLOBAL              1 (SomethingElse)
             15 RAISE_VARARGS            1


So there are benefits even for normal code.

Also the END_FINALLY handling would be really hard to do in a pure
bytecode walker since context from the AST is needed (am I in a
try-finally or try-except or with statement?)
History
Date User Action Args
2009-06-15 19:08:29abbeyjsetrecipients: + abbeyj, collinwinter, rhettinger, pitrou, jyasskin
2009-06-15 19:08:28abbeyjsetmessageid: <1245092908.94.0.917434465219.issue6250@psf.upfronthosting.co.za>
2009-06-15 19:08:27abbeyjlinkissue6250 messages
2009-06-15 19:08:27abbeyjcreate