@@ -11,6 +11,7 @@ use num_bigint::{BigInt, ToBigInt};
1111use num_rational:: Ratio ;
1212use num_traits:: ToPrimitive ;
1313
14+ /// Convert a string or number to a floating point number, if possible.
1415#[ pyclass( name = "float" ) ]
1516#[ derive( Debug , Copy , Clone , PartialEq ) ]
1617pub struct PyFloat {
@@ -222,7 +223,8 @@ impl PyFloat {
222223 )
223224 }
224225
225- fn new_float ( cls : PyClassRef , arg : PyObjectRef , vm : & VirtualMachine ) -> PyResult < PyFloatRef > {
226+ #[ pymethod( name = "__new__" ) ]
227+ fn float_new ( cls : PyClassRef , arg : PyObjectRef , vm : & VirtualMachine ) -> PyResult < PyFloatRef > {
226228 let value = if objtype:: isinstance ( & arg, & vm. ctx . float_type ( ) ) {
227229 get_value ( & arg)
228230 } else if objtype:: isinstance ( & arg, & vm. ctx . int_type ( ) ) {
@@ -408,9 +410,4 @@ pub fn make_float(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult<f64> {
408410#[ rustfmt:: skip] // to avoid line splitting
409411pub fn init ( context : & PyContext ) {
410412 PyFloat :: extend_class ( context, & context. float_type ) ;
411- let float_doc = "Convert a string or number to a floating point number, if possible." ;
412- extend_class ! ( context, & context. float_type, {
413- "__new__" => context. new_rustfunc( PyFloat :: new_float) ,
414- "__doc__" => context. new_str( float_doc. to_string( ) ) ,
415- } ) ;
416413}
0 commit comments