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

Method slot_new

crates/vm/src/builtins/complex.rs:189–202  ·  view source on GitHub ↗
(cls: PyTypeRef, func_args: FuncArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

187 type Args = ComplexArgs;
188
189 fn slot_new(cls: PyTypeRef, func_args: FuncArgs, vm: &VirtualMachine) -> PyResult {
190 // Optimization: return exact complex as-is (only when imag is not provided)
191 if cls.is(vm.ctx.types.complex_type)
192 && func_args.args.len() == 1
193 && func_args.kwargs.is_empty()
194 && func_args.args[0].class().is(vm.ctx.types.complex_type)
195 {
196 return Ok(func_args.args[0].clone());
197 }
198
199 let args: Self::Args = func_args.bind(vm)?;
200 let payload = Self::py_new(&cls, args, vm)?;
201 payload.into_ref_with_type(vm, cls).map(Into::into)
202 }
203
204 fn py_new(_cls: &Py<PyType>, args: Self::Args, vm: &VirtualMachine) -> PyResult<Self> {
205 let imag_missing = args.imag.is_missing();

Callers

nothing calls this directly

Calls 8

isMethod · 0.80
into_ref_with_typeMethod · 0.80
lenMethod · 0.45
is_emptyMethod · 0.45
classMethod · 0.45
cloneMethod · 0.45
bindMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected