1.7 bytecodehacks.find_function_call

find_function_call (infunc, calledfuncname[, allowkeywords])
infunc should be a Function object.

Searches for a call to a function (possibly with keyword arguments) loaded through a global reference to the global name calledfuncname. Returns a simulation of the stack at call time. (if allowkeywords is true, returns (stack,numkeywordargs)).

This ``stack'' contains the opcodes that are responsible for leaving the parameters to the function on the stack. "stack[0]" is the LOAD_GLOBAL instruction that loaded the function and "stack[-1]" is the CALL_FUNCTION instruction responsible for calling the function.

N.B.: when a function is called with m keyword arguments and n positional arguments the stack looks like this:

keyword value m
keyword namem
...
keyword value 2
keyword name 2
keyword value 1
keyword name 1
positional argument n
...
positional argument 2
positional argument 1

So "stack[-2]", "stack[-4]", ..., "stack[-2*numkeywordargs]" are guaranteed to be LOAD_CONST instructions.

Send comments to mwh@python.net