@@ -527,45 +527,29 @@ cdef class fmpz(flint_scalar):
527
527
fmpz_clear(tval)
528
528
return u
529
529
530
- # This is the correct code when fmpz_or is fixed (in flint 3.0.0)
531
-
532
- # def __or__(self, other):
533
- # cdef fmpz_struct tval[1]
534
- # cdef int ttype = FMPZ_UNKNOWN
535
- # ttype = fmpz_set_any_ref(tval, other)
536
- # if ttype == FMPZ_UNKNOWN:
537
- # return NotImplemented
538
- # u = fmpz.__new__(fmpz)
539
- # fmpz_or((<fmpz>u).val, self.val, tval)
540
- # if ttype == FMPZ_TMP:
541
- # fmpz_clear(tval)
542
- # return u
543
-
544
- # def __ror__(self, other):
545
- # cdef fmpz_struct tval[1]
546
- # cdef int ttype = FMPZ_UNKNOWN
547
- # ttype = fmpz_set_any_ref(tval, other)
548
- # if ttype == FMPZ_UNKNOWN:
549
- # return NotImplemented
550
- # u = fmpz.__new__(fmpz)
551
- # fmpz_or((<fmpz>u).val, tval, self.val)
552
- # if ttype == FMPZ_TMP:
553
- # fmpz_clear(tval)
554
- # return u
555
-
556
530
def __or__ (self , other ):
557
- if typecheck(other, fmpz):
558
- other = int (other)
559
- if typecheck(other, int ):
560
- return fmpz(int (self ) | other)
561
- else :
531
+ cdef fmpz_struct tval[1 ]
532
+ cdef int ttype = FMPZ_UNKNOWN
533
+ ttype = fmpz_set_any_ref(tval, other)
534
+ if ttype == FMPZ_UNKNOWN:
562
535
return NotImplemented
536
+ u = fmpz.__new__ (fmpz)
537
+ fmpz_or((< fmpz> u).val, self .val, tval)
538
+ if ttype == FMPZ_TMP:
539
+ fmpz_clear(tval)
540
+ return u
563
541
564
542
def __ror__ (self , other ):
565
- if typecheck(other, int ):
566
- return fmpz(other | int (self ))
567
- else :
543
+ cdef fmpz_struct tval[1 ]
544
+ cdef int ttype = FMPZ_UNKNOWN
545
+ ttype = fmpz_set_any_ref(tval, other)
546
+ if ttype == FMPZ_UNKNOWN:
568
547
return NotImplemented
548
+ u = fmpz.__new__ (fmpz)
549
+ fmpz_or((< fmpz> u).val, tval, self .val)
550
+ if ttype == FMPZ_TMP:
551
+ fmpz_clear(tval)
552
+ return u
569
553
570
554
def __xor__ (self , other ):
571
555
cdef fmpz_struct tval[1 ]
0 commit comments