Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > bytecode JUMP_IF_* always followed by POP_TOP?

Reply
Thread Tools

bytecode JUMP_IF_* always followed by POP_TOP?

 
 
Robert Brewer
Guest
Posts: n/a
 
      04-22-2004
Playing around with bytecodes some more:

>>> def g(x):

.... if x:
.... y
.... else:
.... z
....
>>> dis.dis(g)

2 0 LOAD_FAST 0 (x)
3 JUMP_IF_FALSE 8 (to 14)
6 POP_TOP

3 7 LOAD_GLOBAL 1 (y)
10 POP_TOP
11 JUMP_FORWARD 5 (to 19)
>> 14 POP_TOP


5 15 LOAD_GLOBAL 2 (z)
18 POP_TOP
>> 19 LOAD_CONST 0 (None)

22 RETURN_VALUE

I notice that, whether JUMP_IF_FALSE jumps or not, the next instruction
it executes is POP_TOP (in the above, instruction numbers 6 and 14). Are
there any constructions whereby this does not happen for JUMP_IF_FALSE
and JUMP_IF_TRUE? If there aren't, is it just explicitness that kept
JUMP_IF_* from doing the POP on its own, before the jump (which would
thereby save two instructions)?


Robert Brewer
MIS
Amor Ministries
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
 
Christos TZOTZIOY Georgiou
Guest
Posts: n/a
 
      04-23-2004
On Thu, 22 Apr 2004 13:48:16 -0700, rumours say that "Robert Brewer"
<(E-Mail Removed)> might have written:

>I notice that, whether JUMP_IF_FALSE jumps or not, the next instruction
>it executes is POP_TOP (in the above, instruction numbers 6 and 14).


The following thread is relevant <long URL>:

<URL:http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=bpr6musc14m74uqss78iehtl72h9qrmu7o%404ax .com&rnum=1&prev=/groups%3Fq%3Dgroup%253Acomp.lang.python%2BPOP_TOP% 2Bauthor%253ATZOTZIOY%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den>

Check also my next message in that thread.

I remember the results were not that impressive in pystone and some
other benchmarks (1-2% or less).
--
TZOTZIOY, I speak England very best,
Ils sont fous ces Redmontains! --Harddix
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stylesheets are not followed after migration =?Utf-8?B?QW5kcmU=?= ASP .Net 6 04-13-2006 08:28 PM
Compiler warning: Non-exernalized string literal; it should be followed by //$NON-NLS-<n> Rhino Java 14 12-14-2005 08:55 AM
org.kxml.parser.XmlParser$DefaultParserException: Attribute name ressmust be followed by '='! @8:1764 Fahad Java 0 11-16-2005 02:52 PM
should query string followed by a file name? jrefactors@hotmail.com Java 1 08-12-2005 10:48 PM
REGEX for CUSIP followed by two numbers. Brent ASP .Net 1 07-28-2005 01:52 AM



Advertisments