@@ -239,182 +239,6 @@ impl PyFloat {
239239 . to_owned ( ) )
240240 }
241241
242- #[ pymethod]
243- const fn __abs__ ( & self ) -> f64 {
244- self . value . abs ( )
245- }
246-
247- #[ inline]
248- fn simple_op < F > (
249- & self ,
250- other : PyObjectRef ,
251- op : F ,
252- vm : & VirtualMachine ,
253- ) -> PyResult < PyArithmeticValue < f64 > >
254- where
255- F : Fn ( f64 , f64 ) -> PyResult < f64 > ,
256- {
257- to_op_float ( & other, vm) ?. map_or_else (
258- || Ok ( NotImplemented ) ,
259- |other| Ok ( Implemented ( op ( self . value , other) ?) ) ,
260- )
261- }
262-
263- #[ inline]
264- fn complex_op < F > ( & self , other : PyObjectRef , op : F , vm : & VirtualMachine ) -> PyResult
265- where
266- F : Fn ( f64 , f64 ) -> PyResult ,
267- {
268- to_op_float ( & other, vm) ?. map_or_else (
269- || Ok ( vm. ctx . not_implemented ( ) ) ,
270- |other| op ( self . value , other) ,
271- )
272- }
273-
274- #[ inline]
275- fn tuple_op < F > (
276- & self ,
277- other : PyObjectRef ,
278- op : F ,
279- vm : & VirtualMachine ,
280- ) -> PyResult < PyArithmeticValue < ( f64 , f64 ) > >
281- where
282- F : Fn ( f64 , f64 ) -> PyResult < ( f64 , f64 ) > ,
283- {
284- to_op_float ( & other, vm) ?. map_or_else (
285- || Ok ( NotImplemented ) ,
286- |other| Ok ( Implemented ( op ( self . value , other) ?) ) ,
287- )
288- }
289-
290- #[ pymethod( name = "__radd__" ) ]
291- #[ pymethod]
292- fn __add__ ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult < PyArithmeticValue < f64 > > {
293- self . simple_op ( other, |a, b| Ok ( a + b) , vm)
294- }
295-
296- #[ pymethod]
297- const fn __bool__ ( & self ) -> bool {
298- self . value != 0.0
299- }
300-
301- #[ pymethod]
302- fn __divmod__ (
303- & self ,
304- other : PyObjectRef ,
305- vm : & VirtualMachine ,
306- ) -> PyResult < PyArithmeticValue < ( f64 , f64 ) > > {
307- self . tuple_op ( other, |a, b| inner_divmod ( a, b, vm) , vm)
308- }
309-
310- #[ pymethod]
311- fn __rdivmod__ (
312- & self ,
313- other : PyObjectRef ,
314- vm : & VirtualMachine ,
315- ) -> PyResult < PyArithmeticValue < ( f64 , f64 ) > > {
316- self . tuple_op ( other, |a, b| inner_divmod ( b, a, vm) , vm)
317- }
318-
319- #[ pymethod]
320- fn __floordiv__ (
321- & self ,
322- other : PyObjectRef ,
323- vm : & VirtualMachine ,
324- ) -> PyResult < PyArithmeticValue < f64 > > {
325- self . simple_op ( other, |a, b| inner_floordiv ( a, b, vm) , vm)
326- }
327-
328- #[ pymethod]
329- fn __rfloordiv__ (
330- & self ,
331- other : PyObjectRef ,
332- vm : & VirtualMachine ,
333- ) -> PyResult < PyArithmeticValue < f64 > > {
334- self . simple_op ( other, |a, b| inner_floordiv ( b, a, vm) , vm)
335- }
336-
337- #[ pymethod( name = "__mod__" ) ]
338- fn mod_ ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult < PyArithmeticValue < f64 > > {
339- self . simple_op ( other, |a, b| inner_mod ( a, b, vm) , vm)
340- }
341-
342- #[ pymethod]
343- fn __rmod__ (
344- & self ,
345- other : PyObjectRef ,
346- vm : & VirtualMachine ,
347- ) -> PyResult < PyArithmeticValue < f64 > > {
348- self . simple_op ( other, |a, b| inner_mod ( b, a, vm) , vm)
349- }
350-
351- #[ pymethod]
352- const fn __pos__ ( & self ) -> f64 {
353- self . value
354- }
355-
356- #[ pymethod]
357- const fn __neg__ ( & self ) -> f64 {
358- -self . value
359- }
360-
361- #[ pymethod]
362- fn __pow__ (
363- & self ,
364- other : PyObjectRef ,
365- mod_val : OptionalOption < PyObjectRef > ,
366- vm : & VirtualMachine ,
367- ) -> PyResult {
368- if mod_val. flatten ( ) . is_some ( ) {
369- Err ( vm. new_type_error ( "floating point pow() does not accept a 3rd argument" ) )
370- } else {
371- self . complex_op ( other, |a, b| float_pow ( a, b, vm) , vm)
372- }
373- }
374-
375- #[ pymethod]
376- fn __rpow__ ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult {
377- self . complex_op ( other, |a, b| float_pow ( b, a, vm) , vm)
378- }
379-
380- #[ pymethod]
381- fn __sub__ ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult < PyArithmeticValue < f64 > > {
382- self . simple_op ( other, |a, b| Ok ( a - b) , vm)
383- }
384-
385- #[ pymethod]
386- fn __rsub__ (
387- & self ,
388- other : PyObjectRef ,
389- vm : & VirtualMachine ,
390- ) -> PyResult < PyArithmeticValue < f64 > > {
391- self . simple_op ( other, |a, b| Ok ( b - a) , vm)
392- }
393-
394- #[ pymethod]
395- fn __truediv__ (
396- & self ,
397- other : PyObjectRef ,
398- vm : & VirtualMachine ,
399- ) -> PyResult < PyArithmeticValue < f64 > > {
400- self . simple_op ( other, |a, b| inner_div ( a, b, vm) , vm)
401- }
402-
403- #[ pymethod]
404- fn __rtruediv__ (
405- & self ,
406- other : PyObjectRef ,
407- vm : & VirtualMachine ,
408- ) -> PyResult < PyArithmeticValue < f64 > > {
409- self . simple_op ( other, |a, b| inner_div ( b, a, vm) , vm)
410- }
411-
412- #[ pymethod( name = "__rmul__" ) ]
413- #[ pymethod]
414- fn __mul__ ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult < PyArithmeticValue < f64 > > {
415- self . simple_op ( other, |a, b| Ok ( a * b) , vm)
416- }
417-
418242 #[ pymethod]
419243 fn __trunc__ ( & self , vm : & VirtualMachine ) -> PyResult < BigInt > {
420244 try_to_bigint ( self . value , vm)
@@ -460,16 +284,6 @@ impl PyFloat {
460284 Ok ( value)
461285 }
462286
463- #[ pymethod]
464- fn __int__ ( & self , vm : & VirtualMachine ) -> PyResult < BigInt > {
465- self . __trunc__ ( vm)
466- }
467-
468- #[ pymethod]
469- const fn __float__ ( zelf : PyRef < Self > ) -> PyRef < Self > {
470- zelf
471- }
472-
473287 #[ pygetset]
474288 const fn real ( zelf : PyRef < Self > ) -> PyRef < Self > {
475289 zelf
0 commit comments