MCPcopy Create free account
hub / github.com/python/mypy / py_call

Method py_call

mypyc/irbuild/ll_builder.py:1131–1162  ·  view source on GitHub ↗

Call a Python function (non-native and slow). Use py_call_op or py_call_with_kwargs_op for Python function call.

(
        self,
        function: Value,
        arg_values: list[Value],
        line: int,
        arg_kinds: list[ArgKind] | None = None,
        arg_names: Sequence[str | None] | None = None,
    )

Source from the content-addressed store, hash-verified

1129 return star_result, star2_result
1130
1131 def py_call(
1132 self,
1133 function: Value,
1134 arg_values: list[Value],
1135 line: int,
1136 arg_kinds: list[ArgKind] | None = None,
1137 arg_names: Sequence[str | None] | None = None,
1138 ) -> Value:
1139 """Call a Python function (non-native and slow).
1140
1141 Use py_call_op or py_call_with_kwargs_op for Python function call.
1142 """
1143 result = self._py_vector_call(function, arg_values, line, arg_kinds, arg_names)
1144 if result is not None:
1145 return result
1146
1147 # If all arguments are positional, we can use py_call_op.
1148 if arg_kinds is None or all(kind == ARG_POS for kind in arg_kinds):
1149 return self.call_c(py_call_op, [function] + arg_values, line)
1150
1151 # Otherwise fallback to py_call_with_posargs_op or py_call_with_kwargs_op.
1152 assert arg_names is not None
1153
1154 pos_args_tuple, kw_args_dict = self._construct_varargs(
1155 list(zip(arg_values, arg_kinds, arg_names)), line, has_star=True, has_star2=True
1156 )
1157 assert pos_args_tuple
1158
1159 if kw_args_dict is None:
1160 return self.call_c(py_call_with_posargs_op, [function, pos_args_tuple], line)
1161
1162 return self.call_c(py_call_with_kwargs_op, [function, pos_args_tuple, kw_args_dict], line)
1163
1164 def _py_vector_call(
1165 self,

Callers 2

py_method_callMethod · 0.95
gen_method_callMethod · 0.95

Calls 6

_py_vector_callMethod · 0.95
call_cMethod · 0.95
_construct_varargsMethod · 0.95
allFunction · 0.85
listClass · 0.85
zipFunction · 0.85

Tested by

no test coverage detected