Skip to content

Move Set_PythonType to a separate file #25845

@jdemeyer

Description

@jdemeyer

This is done mainly to avoid cyclic imports when enabling binding=True (#22747).

I'm also removing this pointless implementation of cardinality():

    def cardinality(self):
        from sage.rings.integer import Integer
        two = Integer(2)
        if self._type is bool:
            return two
        elif self._type is int:
            import sys
            return two * sys.maxsize + 2
        elif self._type is float:
            return 2 * two**52 * (two**11 - 1) + 3 # all NaN's are the same from Python's point of view
        else:
            # probably
            import sage.rings.infinity
            return sage.rings.infinity.infinity

Somebody probably found this clever, but it's just silly... who cares how many different int instances there exist? Besides, it's wrong in Python 3.

CC: @tscrim

Component: coercion

Author: Jeroen Demeyer

Branch/Commit: 8005a7b

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/25845

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions