@@ -1782,9 +1782,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
1782
1782
cdef Integer temp
1783
1783
1784
1784
if mpz_sgn(self .value) == 0 :
1785
- temp = PY_NEW(Integer)
1786
- mpz_set_ui(temp.value, 0 )
1787
- return temp
1785
+ return self
1788
1786
1789
1787
if mpz_sgn(self .value) > 0 :
1790
1788
temp = self .exact_log(base)
@@ -1816,7 +1814,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
1816
1814
mpz_add(x.value, (< Integer> left).value, (< Integer> right).value)
1817
1815
return x
1818
1816
elif type (right) is Rational:
1819
- y = < Rational> Rational. __new__ (Rational)
1817
+ y = < Rational> PY_NEW (Rational)
1820
1818
mpq_add_z(y.value, (< Rational> right).value, (< Integer> left).value)
1821
1819
return y
1822
1820
@@ -1899,7 +1897,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
1899
1897
mpz_sub(x.value, (< Integer> left).value, (< Integer> right).value)
1900
1898
return x
1901
1899
elif type (right) is Rational:
1902
- y = < Rational> Rational. __new__ (Rational)
1900
+ y = < Rational> PY_NEW (Rational)
1903
1901
mpz_mul(mpq_numref(y.value), (< Integer> left).value,
1904
1902
mpq_denref((< Rational> right).value))
1905
1903
mpz_sub(mpq_numref(y.value), mpq_numref(y.value),
@@ -2011,7 +2009,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
2011
2009
mpz_mul(x.value, (< Integer> left).value, (< Integer> right).value)
2012
2010
return x
2013
2011
elif type (right) is Rational:
2014
- y = < Rational> Rational. __new__ (Rational)
2012
+ y = < Rational> PY_NEW (Rational)
2015
2013
mpq_mul_z(y.value, (< Rational> right).value, (< Integer> left).value)
2016
2014
return y
2017
2015
@@ -2074,14 +2072,14 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
2074
2072
if type (left) is type (right):
2075
2073
if mpz_sgn((< Integer> right).value) == 0 :
2076
2074
raise ZeroDivisionError (" rational division by zero" )
2077
- x = < Rational> Rational. __new__ (Rational)
2075
+ x = < Rational> PY_NEW (Rational)
2078
2076
mpq_div_zz(x.value, (< Integer> left).value, (< Integer> right).value)
2079
2077
return x
2080
2078
elif type (right) is Rational:
2081
2079
if mpq_sgn((< Rational> right).value) == 0 :
2082
2080
raise ZeroDivisionError (" rational division by zero" )
2083
2081
# left * den(right) / num(right)
2084
- y = < Rational> Rational. __new__ (Rational)
2082
+ y = < Rational> PY_NEW (Rational)
2085
2083
mpq_div_zz(y.value, (< Integer> left).value,
2086
2084
mpq_numref((< Rational> right).value))
2087
2085
mpz_mul(mpq_numref(y.value), mpq_numref(y.value),
@@ -2103,7 +2101,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
2103
2101
"""
2104
2102
if mpz_sgn((< Integer> right).value) == 0 :
2105
2103
raise ZeroDivisionError (" rational division by zero" )
2106
- x = < Rational> Rational. __new__ (Rational)
2104
+ x = < Rational> PY_NEW (Rational)
2107
2105
mpq_div_zz(x.value, self .value, (< Integer> right).value)
2108
2106
return x
2109
2107
@@ -2346,7 +2344,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
2346
2344
else :
2347
2345
if mpz_sgn(self .value) == 0 :
2348
2346
raise ZeroDivisionError (" rational division by zero" )
2349
- q = Rational. __new__ (Rational)
2347
+ q = < Rational> PY_NEW (Rational)
2350
2348
sig_on()
2351
2349
mpz_pow_ui(mpq_denref(q.value), self .value, - n)
2352
2350
if mpz_sgn(mpq_denref(q.value)) > 0 :
@@ -3620,7 +3618,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
3620
3618
ZeroDivisionError: rational reconstruction with zero modulus
3621
3619
"""
3622
3620
cdef Integer a
3623
- cdef Rational x = < Rational> Rational. __new__ (Rational)
3621
+ cdef Rational x = < Rational> PY_NEW (Rational)
3624
3622
try :
3625
3623
mpq_rational_reconstruction(x.value, self .value, m.value)
3626
3624
except ValueError :
@@ -6924,8 +6922,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
6924
6922
"""
6925
6923
if mpz_sgn(self .value) == 0 :
6926
6924
raise ZeroDivisionError (" rational division by zero" )
6927
- cdef Rational x
6928
- x = < Rational> Rational.__new__ (Rational)
6925
+ cdef Rational x = < Rational> PY_NEW(Rational)
6929
6926
mpz_set_ui(mpq_numref(x.value), 1 )
6930
6927
mpz_set(mpq_denref(x.value), self .value)
6931
6928
if mpz_sgn(self .value) == - 1 :
0 commit comments