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 -- http://mail.python.org/mailman/listinfo/python-list