Vectorcall implementation for PyBoundMethod (PEP 590).
(
zelf_obj: &PyObject,
mut args: Vec<PyObjectRef>,
nargs: usize,
kwnames: Option<&[PyObjectRef]>,
vm: &VirtualMachine,
)
| 1430 | |
| 1431 | /// Vectorcall implementation for PyBoundMethod (PEP 590). |
| 1432 | fn 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 | |
| 1448 | pub fn init(context: &'static Context) { |
| 1449 | PyFunction::extend_class(context, context.types.function_type); |
nothing calls this directly
no test coverage detected