@@ -487,29 +487,45 @@ cdef class fmpz(flint_scalar):
487487 fmpz_clear(tval)
488488 return u
489489
490+ # This is the correct code when fmpz_or is fixed (in flint 3.0.0)
491+ #
492+ # def __or__(self, other):
493+ # cdef fmpz_struct tval[1]
494+ # cdef int ttype = FMPZ_UNKNOWN
495+ # ttype = fmpz_set_any_ref(tval, other)
496+ # if ttype == FMPZ_UNKNOWN:
497+ # return NotImplemented
498+ # u = fmpz.__new__(fmpz)
499+ # fmpz_or((<fmpz>u).val, self.val, tval)
500+ # if ttype == FMPZ_TMP:
501+ # fmpz_clear(tval)
502+ # return u
503+ #
504+ # def __ror__(self, other):
505+ # cdef fmpz_struct tval[1]
506+ # cdef int ttype = FMPZ_UNKNOWN
507+ # ttype = fmpz_set_any_ref(tval, other)
508+ # if ttype == FMPZ_UNKNOWN:
509+ # return NotImplemented
510+ # u = fmpz.__new__(fmpz)
511+ # fmpz_or((<fmpz>u).val, tval, self.val)
512+ # if ttype == FMPZ_TMP:
513+ # fmpz_clear(tval)
514+ # return u
515+
490516 def __or__ (self , other ):
491- cdef fmpz_struct tval[1 ]
492- cdef int ttype = FMPZ_UNKNOWN
493- ttype = fmpz_set_any_ref(tval, other)
494- if ttype == FMPZ_UNKNOWN:
517+ if typecheck(other, fmpz):
518+ other = int (other)
519+ if typecheck(other, int ):
520+ return fmpz(int (self ) | other)
521+ else :
495522 return NotImplemented
496- u = fmpz.__new__ (fmpz)
497- fmpz_or((< fmpz> u).val, self .val, tval)
498- if ttype == FMPZ_TMP:
499- fmpz_clear(tval)
500- return u
501523
502524 def __ror__ (self , other ):
503- cdef fmpz_struct tval[1 ]
504- cdef int ttype = FMPZ_UNKNOWN
505- ttype = fmpz_set_any_ref(tval, other)
506- if ttype == FMPZ_UNKNOWN:
525+ if typecheck(other, int ):
526+ return fmpz(other | int (self ))
527+ else :
507528 return NotImplemented
508- u = fmpz.__new__ (fmpz)
509- fmpz_or((< fmpz> u).val, tval, self .val)
510- if ttype == FMPZ_TMP:
511- fmpz_clear(tval)
512- return u
513529
514530 def __xor__ (self , other ):
515531 cdef fmpz_struct tval[1 ]
0 commit comments