Skip to content

Commit 081d67a

Browse files
author
Release Manager
committed
Trac #34922: less usage of python2 long type in padics
URL: https://trac.sagemath.org/34922 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Sebastian Oehms
2 parents 9cff81c + 057771e commit 081d67a

8 files changed

+24
-26
lines changed

src/sage/rings/padics/CA_template.pxi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ cdef class CAElement(pAdicTemplateElement):
5555
5656
INPUT:
5757
58-
- ``x`` -- data defining a `p`-adic element: int, long,
58+
- ``x`` -- data defining a `p`-adic element: int,
5959
Integer, Rational, other `p`-adic element...
6060
6161
- ``val`` -- the valuation of the resulting element
@@ -468,8 +468,7 @@ cdef class CAElement(pAdicTemplateElement):
468468
cdef Integer right
469469
cdef CAElement pright, ans
470470
cdef bint exact_exp
471-
if isinstance(_right, Integer) or isinstance(_right, (int, long)) \
472-
or isinstance(_right, Rational):
471+
if isinstance(_right, (Integer, int, Rational)):
473472
if _right < 0:
474473
base = ~self
475474
return base.__pow__(-_right, dummy)
@@ -490,7 +489,7 @@ cdef class CAElement(pAdicTemplateElement):
490489
elif ciszero(self.value, self.prime_pow):
491490
# We may assume from above that right > 0 if exact.
492491
# So we return a zero of precision right * self.ordp.
493-
if isinstance(_right, (int, long)):
492+
if isinstance(_right, int):
494493
_right = Integer(_right)
495494
if isinstance(_right, Integer):
496495
right = <Integer>_right

src/sage/rings/padics/CR_template.pxi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ cdef class CRElement(pAdicTemplateElement):
8080
8181
INPUT:
8282
83-
- ``x`` -- data defining a `p`-adic element: int, long,
83+
- ``x`` -- data defining a `p`-adic element: int,
8484
Integer, Rational, other `p`-adic element...
8585
8686
- ``val`` -- the valuation of the resulting element
@@ -672,7 +672,7 @@ cdef class CRElement(pAdicTemplateElement):
672672
cdef Integer right
673673
cdef CRElement base, pright, ans
674674
cdef bint exact_exp
675-
if (isinstance(_right, Integer) or isinstance(_right, (int, long)) or isinstance(_right, Rational)):
675+
if isinstance(_right, (Integer, int, Rational)):
676676
if _right < 0:
677677
base = ~self
678678
return base.__pow__(-_right, dummy)
@@ -702,7 +702,7 @@ cdef class CRElement(pAdicTemplateElement):
702702
ans = self._new_c()
703703
if self.relprec == 0:
704704
# If a positive integer exponent, return an inexact zero of valuation right * self.ordp. Otherwise raise an error.
705-
if isinstance(_right, (int, long)):
705+
if isinstance(_right, int):
706706
_right = Integer(_right)
707707
if isinstance(_right, Integer):
708708
right = <Integer>_right

src/sage/rings/padics/FP_template.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ cdef class FPElement(pAdicTemplateElement):
618618
cdef Integer right
619619
cdef FPElement base, pright, ans
620620
cdef bint exact_exp
621-
if isinstance(_right, (Integer, int, long, Rational)):
621+
if isinstance(_right, (Integer, int, Rational)):
622622
if _right < 0:
623623
self = ~self
624624
_right = -_right

src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement):
361361
tmp_Int = PY_NEW(Integer)
362362
ZZ_to_mpz(tmp_Int.value, &(<ntl_ZZ>x).x)
363363
x = tmp_Int
364-
elif isinstance(x, (int, long)):
364+
elif isinstance(x, int):
365365
x = Integer(x)
366366
elif x in parent.residue_field() and x.parent().is_finite():
367367
# Should only reach here if x is not in F_p
@@ -1253,7 +1253,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement):
12531253
cdef long i
12541254
if self._is_inexact_zero():
12551255
# If an integer exponent, return an inexact zero of valuation right * self_ordp. Otherwise raise an error.
1256-
if isinstance(_right, (int, long)):
1256+
if isinstance(_right, int):
12571257
_right = Integer(_right)
12581258
if isinstance(_right, Integer):
12591259
mpz_init_set_si(tmp, self_ordp)
@@ -1270,7 +1270,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement):
12701270
raise ValueError("need more precision")
12711271
else:
12721272
raise TypeError("exponent must be an integer, rational or base p-adic with the same prime")
1273-
if isinstance(_right, (int, long)):
1273+
if isinstance(_right, int):
12741274
_right = Integer(_right)
12751275
cdef pAdicZZpXCAElement unit
12761276
if isinstance(_right, Integer):

src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement):
388388
tmp_Int = PY_NEW(Integer)
389389
ZZ_to_mpz(tmp_Int.value, &(<ntl_ZZ>x).x)
390390
x = tmp_Int
391-
elif isinstance(x, (int, long)):
391+
elif isinstance(x, int):
392392
x = Integer(x)
393393
elif x in parent.residue_field() and x.parent().is_finite():
394394
# Should only reach here if x is not in F_p
@@ -1939,15 +1939,15 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement):
19391939
cdef long i
19401940
if self._is_exact_zero():
19411941
# Return 0 except for 0^0 error or type error on the exponent.
1942-
if isinstance(_right, Integer) or isinstance(_right, Rational) or (isinstance(_right, pAdicGenericElement) and _right._is_base_elt(self.prime_pow.prime)) or isinstance(_right, (int, long)):
1942+
if isinstance(_right, (Integer, Rational, int)) or (isinstance(_right, pAdicGenericElement) and _right._is_base_elt(self.prime_pow.prime)):
19431943
if _right == 0:
19441944
return self.parent(1)
19451945
return self
19461946
else:
19471947
raise TypeError("exponent must be an integer, rational or base p-adic with the same prime")
19481948
elif self._is_inexact_zero():
19491949
# If an integer exponent, return an inexact zero of valuation right * self.ordp. Otherwise raise an error.
1950-
if isinstance(_right, (int, long)):
1950+
if isinstance(_right, int):
19511951
_right = Integer(_right)
19521952
if isinstance(_right, Integer):
19531953
ans = self._new_c(0)
@@ -1962,7 +1962,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement):
19621962
raise ValueError("Need more precision")
19631963
else:
19641964
raise TypeError("exponent must be an integer, rational or base p-adic with the same prime")
1965-
if isinstance(_right, (int, long)):
1965+
if isinstance(_right, int):
19661966
_right = Integer(_right)
19671967
if isinstance(_right, Integer):
19681968
right = <Integer> _right

src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement):
260260
tmp_Int = Integer.__new__(Integer)
261261
ZZ_to_mpz(tmp_Int.value, &(<ntl_ZZ>x).x)
262262
x = tmp_Int
263-
elif isinstance(x, (int, long)):
263+
elif isinstance(x, int):
264264
x = Integer(x)
265265
if isinstance(x, Integer):
266266
self._set_from_mpz((<Integer>x).value)

src/sage/rings/padics/padic_ZZ_pX_element.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ cdef preprocess_list(pAdicZZpXElement elt, L):
658658
for i from 0 <= i < len(L):
659659
if isinstance(L[i], ntl_ZZ):
660660
L[i] = ntl_ZZ_p(L[i]*pshift_z, ctx)
661-
elif isinstance(L[i], Integer) or isinstance(L[i], Rational) or isinstance(L[i], (int, long)):
661+
elif isinstance(L[i], (Integer, Rational, int)):
662662
L[i] = ntl_ZZ_p(L[i]*pshift_m, ctx)
663663
elif isinstance(L[i], pAdicGenericElement) and L[i]._is_base_elt(elt.prime_pow.prime):
664664
L[i] = ntl_ZZ_p((L[i] >> min_val).lift(), ctx)
@@ -676,7 +676,7 @@ cdef preprocess_list(pAdicZZpXElement elt, L):
676676
py_tmp = ntl_ZZ.__new__(ntl_ZZ)
677677
py_tmp.x = tmp
678678
L[i] = ntl_ZZ_p(py_tmp, ctx)
679-
elif isinstance(L[i], Integer) or isinstance(L[i], Rational) or isinstance(L[i], (int, long)):
679+
elif isinstance(L[i], (Integer, Rational, int)):
680680
L[i] = ntl_ZZ_p(L[i]//pshift_m, ctx)
681681
elif isinstance(L[i], pAdicGenericElement) and L[i]._is_base_elt(elt.prime_pow.prime):
682682
L[i] = ntl_ZZ_p((L[i] >> min_val).lift(), ctx)
@@ -689,7 +689,7 @@ cdef preprocess_list(pAdicZZpXElement elt, L):
689689
L[i] = ntl_ZZ_p(py_tmp, ctx)
690690
else:
691691
for i from 0 <= i < len(L):
692-
if isinstance(L[i], ntl_ZZ) or isinstance(L[i], Integer) or isinstance(L[i], Rational) or isinstance(L[i], (int, long)):
692+
if isinstance(L[i], (ntl_ZZ, Integer, Rational, int)):
693693
L[i] = ntl_ZZ_p(L[i], ctx)
694694
elif (isinstance(L[i], pAdicGenericElement) and L[i]._is_base_elt(elt.prime_pow.prime)) or is_IntegerMod(L[i]) or (L[i].modulus_context() is not ctx):
695695
L[i] = ntl_ZZ_p(L[i].lift(), ctx)
@@ -865,7 +865,7 @@ cdef get_val_prec(PowComputer_ext pp, a):
865865
py_tmp = ntl_ZZ.__new__(ntl_ZZ)
866866
py_tmp.x = pp.pow_ZZ_tmp(1)[0]
867867
return (Integer(a.valuation(py_tmp)), big, two)
868-
if isinstance(a, (int, long)):
868+
if isinstance(a, int):
869869
if a == 0:
870870
return (big, big, two)
871871
return (Integer(a).valuation(pp.prime), big, two)

src/sage/rings/padics/padic_template_element.pxi

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ AUTHORS:
1111
1212
- David Roe -- initial version (2012-3-1)
1313
"""
14-
15-
#*****************************************************************************
14+
# ****************************************************************************
1615
# Copyright (C) 2007-2013 David Roe <[email protected]>
1716
# William Stein <[email protected]>
1817
#
1918
# Distributed under the terms of the GNU General Public License (GPL)
2019
# as published by the Free Software Foundation; either version 2 of
2120
# the License, or (at your option) any later version.
2221
#
23-
# http://www.gnu.org/licenses/
24-
#*****************************************************************************
22+
# https://www.gnu.org/licenses/
23+
# ****************************************************************************
2524

2625
from cpython.int cimport *
2726

@@ -120,7 +119,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement):
120119
pAdicGenericElement.__init__(self, parent)
121120
cdef long val, xprec
122121
cdef GEN pari_tmp
123-
if isinstance(x, (int, long)):
122+
if isinstance(x, int):
124123
x = Integer(x)
125124
elif isinstance(x, pari_gen):
126125
pari_tmp = (<pari_gen>x).g
@@ -776,7 +775,7 @@ cdef Integer exact_pow_helper(long *ansrelprec, long relprec, _right, PowCompute
776775
cdef Integer right, p = prime_pow.prime
777776
cdef long exp_val
778777
cdef bint isbase
779-
if isinstance(_right, (int, long)):
778+
if isinstance(_right, int):
780779
_right = Integer(_right)
781780
if isinstance(_right, Integer):
782781
right = <Integer> _right

0 commit comments

Comments
 (0)