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