[issue1394] simple patch, improving unreachable bytecode removing

2008-06-24 Thread Raymond Hettinger
Raymond Hettinger [EMAIL PROTECTED] added the comment: Recommend rejecting. Too much work for zero performance payoff. -- assignee: rhettinger - ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1394

[issue1394] simple patch, improving unreachable bytecode removing

2008-06-24 Thread Guido van Rossum
Guido van Rossum [EMAIL PROTECTED] added the comment: Rejecting. Too much risk as well, based on experience in the past with supposedly harmless optimizations. -- resolution: - rejected status: open - closed ___ Python tracker [EMAIL PROTECTED]

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I have added more tests as Neal suggested. See unreachable-code-with- tests.diff for a combined patch. I've rerun all tests after removing .pyc files and also with -O option (ensuring no existing .pyo files as well). All works. I've removed #if 0

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-26 Thread Paul Pogonyshev
Paul Pogonyshev added the comment: Well, I cannot guarantee it will _always_ be eliminated, since I too don't really know when generated bytecode can (currently) end in non-return. However, if before it ended in non-return, that non-return must have been unreachable, obviously (else code flow

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-26 Thread Paul Pogonyshev
Paul Pogonyshev added the comment: Actually, it is even better. Since you don't increment codelen, that extra RETURN_VALUE is virtual in that it acts as a sentinel, but will not appear in the resulting bytecode. You can test this by backing out the patch and disassembling something. For this

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Since you don't increment codelen .. Good catch! For this reason, if() before writing the RETURN_VALUE is not needed. In this case it will be clearer to use STOP_CODE instead of RETURN_VALUE as a sentinel. __ Tracker

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Paul Pogonyshev
Paul Pogonyshev added the comment: Yes, help with unit tests would be appreciated. Especially since it is not supposed to fix anything, so I'm not sure what unit tests should be like... BTW, trying to understand why the patch didn't remove unreachable code in your first example, I noticed this

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Paul Pogonyshev
Paul Pogonyshev added the comment: Speaking of which, I propose that codestr[] array is made one byte longer and RETURN_VALUE opcode wrote in that extra byte. It will be removed by this patch anyway (if it is accepted), but we'll remove a way to accidentally disable peephole optimizer. I mean,

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Benjamin Peterson
Benjamin Peterson added the comment: Yes, help with unit tests would be appreciated. Especially since it is not supposed to fix anything, so I'm not sure what unit tests should be like... Unit tests are just for bugfixes. They let us make sure Python is doing what we want it to do in a given

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Guido van Rossum
Guido van Rossum added the comment: On Mon, Feb 25, 2008 at 1:32 PM, Benjamin Peterson [EMAIL PROTECTED] wrote: Unit tests are just for bugfixes. I presume you meant are *not* just for bugfixes. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1394

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Benjamin Peterson
Benjamin Peterson added the comment: I presume you meant are *not* just for bugfixes. (Sigh) Yes, of course. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1394 __ ___

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Raymond Hettinger
Changes by Raymond Hettinger: -- assignee: - rhettinger nosy: +rhettinger __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1394 __ ___ Python-bugs-list mailing list

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Paul Pogonyshev
Paul Pogonyshev added the comment: Thanks for writing the test. Yes, I did read the comment. As I understood it, RETURN_VALUE is needed only so that various optimization can assume codestr[] cannot suddenly end without one. E.g. if you match for BINARY_ADD, you can safely check the next

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Paul, You are right. I misunderstood that comment myself. I've tried the attached modification to your patch (unreachable-code-1.diff) and it passes all tests while fixing msg62953 problem: $ cat t.py def f(): return 1 1+2 from dis import

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am not sure what this patch would accomplish. I tried $ cat t.py def f(): return 1 1+2 from dis import dis print dis(f) Both with and without patch I get $ ./python.exe -O t.py 2 0 LOAD_CONST 1 (1) 3

[issue1394] simple patch, improving unreachable bytecode removing

2008-02-24 Thread Neal Norwitz
Neal Norwitz added the comment: It would be great to see test cases with this change. That would help answer Alexander's question too. -- nosy: +nnorwitz __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1394 __

[issue1394] simple patch, improving unreachable bytecode removing

2007-11-06 Thread Guido van Rossum
Changes by Guido van Rossum: -- nosy: +gvanrossum __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1394 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1394] simple patch, improving unreachable bytecode removing

2007-11-05 Thread Paul Pogonyshev
New submission from Paul Pogonyshev: This patch improves bytecode output, by removing unreachable code. It doesn't target special cases, as now, but provides a generic implementation. -- components: Interpreter Core files: unreachable-code.diff messages: 57141 nosy: Paul Pogonyshev