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

Method py_new

crates/vm/src/builtins/float.rs:188–200  ·  view source on GitHub ↗
(_cls: &Py<PyType>, arg: Self::Args, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

186 }
187
188 fn py_new(_cls: &Py<PyType>, arg: Self::Args, vm: &VirtualMachine) -> PyResult<Self> {
189 let float_val = match arg {
190 OptionalArg::Missing => 0.0,
191 OptionalArg::Present(val) => {
192 if let Some(f) = val.try_float_opt(vm) {
193 f?.value
194 } else {
195 float_from_string(val, vm)?
196 }
197 }
198 };
199 Ok(Self::from(float_val))
200 }
201}
202
203fn float_from_string(val: PyObjectRef, vm: &VirtualMachine) -> PyResult<f64> {

Callers

nothing calls this directly

Calls 2

float_from_stringFunction · 0.85
try_float_optMethod · 0.80

Tested by

no test coverage detected