472,331 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

Are the CALL_FUNCTION_* opcodes ever used?

Hi folks!

Studying python byte code I encountered an interesting issue: there is no
matter, which one of the following function calls I compile:

1: func('foo','bar',foo='bar')
2: func('foobar')
3: func(foo='bar')

The compiler always uses the simple CALL_FUNCTION for all of the source
examples above. While this is fine for me (since the labels in Python/ceval.c
for the other 3 opcodes lead to the same code anyway), I'm curious to know
if there is a case where the compiler really uses the CALL_FUNCTION_* opcodes
or if we could silently remove these opcodes without breaking anything?

Greetings,
Fips
Sep 21 '06 #1
2 1172
Fabiano Sidler wrote:
Studying python byte code I encountered an interesting issue: there is no
matter, which one of the following function calls I compile:

1: func('foo','bar',foo='bar')
2: func('foobar')
3: func(foo='bar')

The compiler always uses the simple CALL_FUNCTION for all of the source
examples above. While this is fine for me (since the labels in
Python/ceval.c for the other 3 opcodes lead to the same code anyway), I'm
curious to know if there is a case where the compiler really uses the
CALL_FUNCTION_* opcodes or if we could silently remove these opcodes
without breaking anything?
>>def test():
.... func(*args)
.... func(**kw)
.... func(*args, **kw)
....
>>dis.dis(test)
2 0 LOAD_GLOBAL 0 (func)
3 LOAD_GLOBAL 1 (args)
6 CALL_FUNCTION_VAR 0
9 POP_TOP

3 10 LOAD_GLOBAL 0 (func)
13 LOAD_GLOBAL 2 (kw)
16 CALL_FUNCTION_KW 0
19 POP_TOP

4 20 LOAD_GLOBAL 0 (func)
23 LOAD_GLOBAL 1 (args)
26 LOAD_GLOBAL 2 (kw)
29 CALL_FUNCTION_VAR_KW 0
32 POP_TOP
33 LOAD_CONST 0 (None)
36 RETURN_VALUE

So there.

Peter
Sep 21 '06 #2
On Thursday 21 September 2006 22:36, Peter Otten wrote:
>def test():

... func(*args)
... func(**kw)
... func(*args, **kw)
Oh, I didn't know the possibility of using the *args and **kwargs semantics
at function call. Thank you for revealing them to me! :)
Now it is also obvious how the CALL_FUNCTION_* opcodes are used.

Greetings,
Fips
Sep 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Lyle Fairfield | last post by:
I was just showing a youngster some MS-SQL stuff on a remote Internet enabled shared server. He logged in with my User Name and Password. I was...
10
by: LaEisem | last post by:
On-the-job, I have "inherited" a lot of old C language software. A question or two about when "casting" of null pointer constants is needed has...
2
by: Striped | last post by:
Is there any tool to convert source code, e.g. of a C# method, to opcodes being used in System.Reflection.Emit? It's a real pain to do that...
5
by: Toby Webb | last post by:
How can I convert the following code (from MSDN) to work in VB.NET (the opcodes are raising errors): Public Enum WLAN_INTF_OPCODE...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.