Re: [Python-Dev] Generated Bytecode ...

2015-11-01 Thread Meador Inge
On Fri, Oct 23, 2015 at 3:23 AM, Victor Stinner wrote: > Note: I propose "noopt" because we already have "optimization level 0" > which still uses optimizations, it's the default mode. It's different > than gcc -O0 which really disables all optimizations. I already

Re: [Python-Dev] Generated Bytecode ...

2015-10-26 Thread Terry Reedy
On 10/23/2015 4:23 AM, Victor Stinner wrote: Hi, 2015-10-22 19:02 GMT+02:00 Brett Cannon : It's not specified anywhere; it's just what the peepholer decides to remove. The exact code can be found at https://hg.python.org/cpython/file/default/Python/peephole.c . There has been

Re: [Python-Dev] Generated Bytecode ...

2015-10-26 Thread Victor Stinner
2015-10-24 4:34 GMT+09:00 Terry Reedy : > How about -x nopeep to specifically skip the peephole optimizer? Raymond wrote "IIRC, the code was never generated in the first place (before the peephole pass)." So "nopeep" would have a different purpose. Victor

Re: [Python-Dev] Generated Bytecode ...

2015-10-26 Thread Terry Reedy
On 10/26/2015 10:36 PM, Victor Stinner wrote: 2015-10-24 4:34 GMT+09:00 Terry Reedy : How about -x nopeep to specifically skip the peephole optimizer? Raymond wrote "IIRC, the code was never generated in the first place (before the peephole pass)." I based that suggestion

Re: [Python-Dev] Generated Bytecode ...

2015-10-25 Thread Raymond Hettinger
> On Oct 25, 2015, at 12:33 PM, Raymond Hettinger > wrote: > >> On Oct 22, 2015, at 10:02 AM, Brett Cannon wrote: >> >> So my question is, the byte code generator removes the unused functions, >> variables etc…, is it right? >> >> Technically

Re: [Python-Dev] Generated Bytecode ...

2015-10-25 Thread Raymond Hettinger
> On Oct 22, 2015, at 10:02 AM, Brett Cannon wrote: > > So my question is, the byte code generator removes the unused functions, > variables etc…, is it right? > > Technically the peepholer removes the dead branch, but since the peepholer is > run on all bytecode you can't

Re: [Python-Dev] Generated Bytecode ...

2015-10-25 Thread Stephane Wirtel
Thank you for your confirmation, I am going to read the devguide. > On 25 oct. 2015, at 7:50 PM, Raymond Hettinger > wrote: > > >>> On Oct 25, 2015, at 12:33 PM, Raymond Hettinger >>> wrote: >>> >>> On Oct 22, 2015, at 10:02 AM,

Re: [Python-Dev] Generated Bytecode ...

2015-10-23 Thread Victor Stinner
Hi, 2015-10-22 19:02 GMT+02:00 Brett Cannon : > It's not specified anywhere; it's just what the peepholer decides to remove. > The exact code can be found at > https://hg.python.org/cpython/file/default/Python/peephole.c . There has > been talk in the past for adding a -X flag

Re: [Python-Dev] Generated Bytecode ...

2015-10-22 Thread R. David Murray
On Thu, 22 Oct 2015 17:02:48 -, Brett Cannon wrote: > On Thu, 22 Oct 2015 at 09:37 Stéphane Wirtel wrote: > > > Hi all, > > > > When we compile a python script > > > > # test.py > > if 0: > > x = 1 > > > > python -mdis test.py > > > > There is

Re: [Python-Dev] Generated Bytecode ...

2015-10-22 Thread Brett Cannon
On Thu, 22 Oct 2015 at 09:37 Stéphane Wirtel wrote: > Hi all, > > When we compile a python script > > # test.py > if 0: > x = 1 > > python -mdis test.py > > There is no byte code for the condition. > > So my question is, the byte code generator removes the unused

Re: [Python-Dev] Generated Bytecode ...

2015-10-22 Thread Chris Angelico
On Fri, Oct 23, 2015 at 3:05 PM, Terry Reedy wrote: > Indeed, whether 'pass' should be compiled to 'NOP' or nothing depends on > one's view of the meaning of pass and whether it must be executed (by going > though the ceval loop once and doing nothing) or not. Hmm. I thought

Re: [Python-Dev] Generated Bytecode ...

2015-10-22 Thread Terry Reedy
On 10/22/2015 1:56 PM, R. David Murray wrote: On Thu, 22 Oct 2015 17:02:48 -, Brett Cannon wrote: On Thu, 22 Oct 2015 at 09:37 Stéphane Wirtel wrote: Hi all, When we compile a python script # test.py if 0: x = 1 python -mdis test.py

[Python-Dev] Generated Bytecode ...

2015-10-22 Thread Stéphane Wirtel
Hi all, When we compile a python script # test.py if 0: x = 1 python -mdis test.py There is no byte code for the condition. So my question is, the byte code generator removes the unused functions, variables etc…, is it right? What are the cases where the generator does not generate

Re: [Python-Dev] Generated Bytecode ...

2015-10-22 Thread Stéphane Wirtel
Thank you Brett, I am going to read the source code, I am going to give a presentation at PyCon.IE about this part and I wanted to be sure about the dead branches. Thanks On 22 Oct 2015, at 19:02, Brett Cannon wrote: > On Thu, 22 Oct 2015 at 09:37 Stéphane Wirtel wrote: >