diff --git a/src/sage/rings/integer.pxd b/src/sage/rings/integer.pxd index 2f81c164943..b831f095eb1 100644 --- a/src/sage/rings/integer.pxd +++ b/src/sage/rings/integer.pxd @@ -42,6 +42,3 @@ cdef inline Integer _Integer_from_mpz(mpz_t e) noexcept: cdef Integer z = Integer.__new__(Integer) mpz_set(z.value, e) return z - -cdef class int_to_Z(Morphism): - pass diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index aa7d4855bbb..4b837947047 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -7390,87 +7390,6 @@ def make_integer(s): cdef class int_to_Z(Morphism): - """ - Morphism from Python ints to Sage integers. - - EXAMPLES:: - - sage: f = ZZ.coerce_map_from(int) - sage: type(f) - - sage: f(5r) - 5 - sage: type(f(5r)) - - sage: 1 + 2r - 3 - sage: type(1 + 2r) - - - This is intended for internal use by the coercion system, - to facilitate fast expressions mixing ints and more complex - Python types. Note that (as with all morphisms) the input - is forcably coerced to the domain ``int`` if it is not - already of the correct type which may have undesirable results:: - - sage: f.domain() - Set of Python objects of class 'int' - sage: f(1/3) - 0 - sage: f(1.7) - 1 - sage: f("10") - 10 - - A pool is used for small integers:: - - sage: f(10) is f(10) - True - sage: f(-2) is f(-2) - True - """ - - def __init__(self): - """ - TESTS:: - - sage: f = ZZ.coerce_map_from(int) - sage: f.parent() - Set of Morphisms from Set of Python objects of class 'int' to Integer Ring in Category of sets - """ - import sage.categories.homset - from sage.sets.pythonclass import Set_PythonType - Morphism.__init__(self, sage.categories.homset.Hom(Set_PythonType(int), integer_ring.ZZ)) - - cpdef Element _call_(self, a) noexcept: - """ - Return a new integer with the same value as ``a``. - - TESTS:: - - sage: f = ZZ.coerce_map_from(int) - sage: f(100r) - 100 - """ - if type(a) is not int: - raise TypeError("must be a Python int object") - - return smallInteger(PyLong_AsLong(a)) - - def _repr_type(self): - """ - TESTS:: - - sage: f = ZZ.coerce_map_from(int) - sage: print(f) - Native morphism: - From: Set of Python objects of class 'int' - To: Integer Ring - """ - return "Native" - - -cdef class long_to_Z(Morphism): """ EXAMPLES:: diff --git a/src/sage/rings/integer_ring.pyx b/src/sage/rings/integer_ring.pyx index 559de2065e2..e35559d68d8 100644 --- a/src/sage/rings/integer_ring.pyx +++ b/src/sage/rings/integer_ring.pyx @@ -586,9 +586,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): sage: f(-7r) -7 """ - if S is long: - return sage.rings.integer.long_to_Z() - elif S is int: + if S is int: return sage.rings.integer.int_to_Z() elif S is bool: return True