[issue11471] If without else generates redundant jump

2014-09-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Pushed after applying Serhiy's suggestion. Thank you!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2014-09-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c0ca9d32aed4 by Antoine Pitrou in branch 'default':
Closes #11471: avoid generating a JUMP_FORWARD instruction at the end of an 
if-block if there is no else-clause.
https://hg.python.org/cpython/rev/c0ca9d32aed4

--
nosy: +python-dev
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2014-09-08 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2014-09-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM.

Attila Fazekas just has provided almost the same patch in issue22358.

--
stage: patch review -> commit review
versions: +Python 3.5 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2013-12-22 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +serhiy.storchaka
stage:  -> patch review
versions: +Python 3.4 -Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2013-10-14 Thread Georg Brandl

Georg Brandl added the comment:

Yep :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2013-10-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Just for the record, have you passed the whole test suite after cleaning up the 
pyc files,

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2013-10-14 Thread Benjamin Peterson

Benjamin Peterson added the comment:

lgtm

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2013-10-14 Thread Georg Brandl

Georg Brandl added the comment:

Updated patch with test suite update.

--
Added file: http://bugs.python.org/file32120/if_else_nojump_2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2013-10-14 Thread Benjamin Peterson

Benjamin Peterson added the comment:

I think it's fine with the simplification I suggested.

--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2013-10-14 Thread Georg Brandl

Georg Brandl added the comment:

I'll make a complete patch with test suite additions (and fixing test_dis) if 
this is deemed to be a correct approach.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2013-10-14 Thread Georg Brandl

Georg Brandl added the comment:

Python-ast.c can't be changed; it is auto-generated.  But the whole thing can 
be handled in compile.c I think -- see attached patch.  Test suite passes 
(except for test_dis, which checks compilation result against a given list of 
bytecodes).

--
nosy: +georg.brandl, pitrou, rhettinger
Added file: http://bugs.python.org/file32117/if_else_nojump.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2011-03-11 Thread Eugene Toder

Eugene Toder  added the comment:

Test case (needed some refactoring to avoid duplication).

--
Added file: http://bugs.python.org/file21092/if_no_else_test.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11471] If without else generates redundant jump

2011-03-11 Thread Eugene Toder

New submission from Eugene Toder :

If statement without else part generates unnecessary JUMP_FORWARD insn with 
jumps right to the next insn:

>>> def foo(x):
if x: x = 1

>>> dis(foo)
  2   0 LOAD_FAST0 (x) 
  3 POP_JUMP_IF_FALSE   15 
  6 LOAD_CONST   1 (1) 
  9 STORE_FAST   0 (x) 
 12 JUMP_FORWARD 0 (to 15) 
>>   15 LOAD_CONST   0 (None) 
 18 RETURN_VALUE 

This patch suppresses generation of this jump.

Testing revealed another issue: when AST is produced from string empty 'orelse' 
sequences are represented with NULLs. However when AST is converted from Python 
AST objects empty 'orelse' is a pointer to 0-length sequence. I've changed this 
to produce NULL pointers, like in the string case. This uses less memory and 
doesn't introduce different code path in compiler. Without this change 
test_compile failed with my first change.

make test passes.

--
components: Interpreter Core
files: if_no_else.patch
keywords: patch
messages: 130623
nosy: eltoder
priority: normal
severity: normal
status: open
title: If without else generates redundant jump
type: performance
versions: Python 3.3
Added file: http://bugs.python.org/file21091/if_no_else.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com