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

Function vectorcall_bound_method

crates/vm/src/builtins/function.rs:1432–1446  ·  view source on GitHub ↗

Vectorcall implementation for PyBoundMethod (PEP 590).

(
    zelf_obj: &PyObject,
    mut args: Vec<PyObjectRef>,
    nargs: usize,
    kwnames: Option<&[PyObjectRef]>,
    vm: &VirtualMachine,
)

Source from the content-addressed store, hash-verified

1430
1431/// Vectorcall implementation for PyBoundMethod (PEP 590).
1432fn vectorcall_bound_method(
1433 zelf_obj: &PyObject,
1434 mut args: Vec<PyObjectRef>,
1435 nargs: usize,
1436 kwnames: Option<&[PyObjectRef]>,
1437 vm: &VirtualMachine,
1438) -> PyResult {
1439 let zelf: &Py<PyBoundMethod> = zelf_obj.downcast_ref().unwrap();
1440
1441 // Insert self at front of existing Vec (avoids 2nd allocation).
1442 // O(n) memmove is cheaper than a 2nd heap alloc+dealloc for typical arg counts.
1443 args.insert(0, zelf.object.clone());
1444 let new_nargs = nargs + 1;
1445 zelf.function.vectorcall(args, new_nargs, kwnames, vm)
1446}
1447
1448pub fn init(context: &'static Context) {
1449 PyFunction::extend_class(context, context.types.function_type);

Callers

nothing calls this directly

Calls 5

downcast_refMethod · 0.80
unwrapMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
vectorcallMethod · 0.45

Tested by

no test coverage detected