Move Set_PythonType to a separate file
jdemeyer opened this issue · 7 comments
jdemeyer commented
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
jdemeyer commented
Description changed:
---
+++
@@ -1 +1,21 @@
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.jdemeyer commented
Branch: u/jdemeyer/ticket/25845
tscrim commented
comment:4
Green bot => positive review.
tscrim commented
Reviewer: Travis Scrimshaw
vbraun commented
Changed branch from u/jdemeyer/ticket/25845 to 8005a7b