MCPcopy Index your code
hub / github.com/RustPython/RustPython / invoke

Method invoke

crates/vm/src/protocol/callable.rs:75–98  ·  view source on GitHub ↗
(&self, args: impl IntoFuncArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

73 }
74
75 pub fn invoke(&self, args: impl IntoFuncArgs, vm: &VirtualMachine) -> PyResult {
76 let args = args.into_args(vm);
77 if !vm.use_tracing.get() {
78 return (self.call)(self.obj, args, vm);
79 }
80 // Python functions get 'call'/'return' events from with_frame().
81 // Bound methods delegate to the inner callable, which fires its own events.
82 // All other callables (built-in functions, etc.) get 'c_call'/'c_return'/'c_exception'.
83 let is_python_callable = self.obj.downcast_ref::<PyFunction>().is_some()
84 || self.obj.downcast_ref::<PyBoundMethod>().is_some();
85 if is_python_callable {
86 (self.call)(self.obj, args, vm)
87 } else {
88 let callable = self.obj.to_owned();
89 vm.trace_event(TraceEvent::CCall, Some(callable.clone()))?;
90 let result = (self.call)(self.obj, args, vm);
91 if result.is_ok() {
92 vm.trace_event(TraceEvent::CReturn, Some(callable))?;
93 } else {
94 let _ = vm.trace_event(TraceEvent::CException, Some(callable));
95 }
96 result
97 }
98 }
99
100 /// Vectorcall dispatch: use vectorcall slot if available, else fall back to FuncArgs.
101 #[inline]

Callers 4

try_intMethod · 0.45
strMethod · 0.45
call_with_argsMethod · 0.45
invoke_vectorcallMethod · 0.45

Calls 6

trace_eventMethod · 0.80
SomeClass · 0.50
into_argsMethod · 0.45
getMethod · 0.45
to_ownedMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected