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

Method invoke_vectorcall

crates/vm/src/protocol/callable.rs:102–133  ·  view source on GitHub ↗
(
        &self,
        args: Vec<PyObjectRef>,
        nargs: usize,
        kwnames: Option<&[PyObjectRef]>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

100 /// Vectorcall dispatch: use vectorcall slot if available, else fall back to FuncArgs.
101 #[inline]
102 pub fn invoke_vectorcall(
103 &self,
104 args: Vec<PyObjectRef>,
105 nargs: usize,
106 kwnames: Option<&[PyObjectRef]>,
107 vm: &VirtualMachine,
108 ) -> PyResult {
109 if let Some(vc) = self.vectorcall {
110 if !vm.use_tracing.get() {
111 return vc(self.obj, args, nargs, kwnames, vm);
112 }
113 let is_python_callable = self.obj.downcast_ref::<PyFunction>().is_some()
114 || self.obj.downcast_ref::<PyBoundMethod>().is_some();
115 if is_python_callable {
116 vc(self.obj, args, nargs, kwnames, vm)
117 } else {
118 let callable = self.obj.to_owned();
119 vm.trace_event(TraceEvent::CCall, Some(callable.clone()))?;
120 let result = vc(self.obj, args, nargs, kwnames, vm);
121 if result.is_ok() {
122 vm.trace_event(TraceEvent::CReturn, Some(callable))?;
123 } else {
124 let _ = vm.trace_event(TraceEvent::CException, Some(callable));
125 }
126 result
127 }
128 } else {
129 // Fallback: convert owned Vec to FuncArgs (move, no clone)
130 let func_args = FuncArgs::from_vectorcall_owned(args, nargs, kwnames);
131 self.invoke(func_args, vm)
132 }
133 }
134}
135
136/// Trace events for sys.settrace and sys.setprofile.

Callers 1

vectorcallMethod · 0.80

Calls 6

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

Tested by

no test coverage detected