@@ -107,9 +107,6 @@ cdef class fmpq(flint_scalar):
107107
108108 def __richcmp__ (s , t , int op ):
109109 cdef bint res
110- s = any_as_fmpq(s)
111- if s is NotImplemented :
112- return s
113110 t = any_as_fmpq(t)
114111 if t is NotImplemented :
115112 return t
@@ -119,12 +116,12 @@ cdef class fmpq(flint_scalar):
119116 res = not res
120117 return res
121118 else :
122- # todo: use fmpq_cmp when available
123- if op == 0 : res = (s - t).p < 0
124- elif op == 1 : res = (s - t).p <= 0
125- elif op == 4 : res = (s - t).p > 0
126- elif op == 5 : res = (s - t).p >= 0
127- else : raise ValueError
119+ res = fmpq_cmp(s.val, ( < fmpq > t).val)
120+ if op == 0 : res = res < 0
121+ elif op == 1 : res = res <= 0
122+ elif op == 4 : res = res > 0
123+ elif op == 5 : res = res >= 0
124+ else : assert False
128125 return res
129126
130127 def numer (self ):
@@ -437,9 +434,9 @@ cdef class fmpq(flint_scalar):
437434 import sys
438435 from fractions import Fraction
439436 if sys.version_info < (3 , 12 ):
440- return hash (Fraction(int (self .p), int (self .q), _normalize = False ))
437+ return hash (Fraction(int (self .p), int (self .q), _normalize = False )) # pragma: no cover
441438 else :
442- return hash (Fraction._from_coprime_ints(int (self .p), int (self .q)))
439+ return hash (Fraction._from_coprime_ints(int (self .p), int (self .q))) # pragma: no cover
443440
444441 def height_bits (self , bint signed = False ):
445442 """
0 commit comments