sage.arith: Use sage.rings.abc and move some module-level imports into methods
Closed this issue · 9 comments
mkoeppe commented
(cherry-picked from #32432)
Depends on #32566
CC: @tscrim
Component: refactoring
Author: Matthias Koeppe
Branch/Commit: 5e5843a
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/32600
mkoeppe commented
mkoeppe commented
New commits:
cee081a | sage.rings.real_mpfr.RealField_class: Inherit through a new class sage.rings.abc.RealField |
99f4f10 | sage.rings.real_double.RealDoubleField_class: Inherit through a new class sage.rings.abc.RealDoubleField |
29871d0 | ComplexField_class, ComplexDoubleField: Inherit through new classes sage.rings.abc.* |
e1bb944 | src/sage/rings/polynomial/polynomial_element.pyx: Replace use of is_RealField by isinstance(sage.rings.abc.RealField) etc. |
6e2c3c4 | src/sage/rings/abc.pyx: Add class docstrings |
2bd66e4 | Merge #32566 |
4e2f0ab | src/sage/arith/misc.py: move pari/flint imports into methods |
5145d43 | src/sage/arith/misc.py: Use sage.rings.abc instead of importing element classes RealNumber, ComplexNumber |
5e5843a | sage.arith.misc: Fixup |
mkoeppe commented
Author: Matthias Koeppe
tscrim commented
comment:5
While it's not an issue here since it is not the main part of the algorithm, changes like this do incur a slight performance penalty:
- if isinstance(z, (RealNumber, ComplexNumber)):
+ if isinstance(z.parent(), (RealField, ComplexField)):This is just for future reference.
tscrim commented
Reviewer: Travis Scrimshaw
mkoeppe commented
comment:6
Thanks! I agree with your analysis.
vbraun commented
Changed branch from u/mkoeppe/sage_arith__use_sage_rings_abc_and_move_some_module_level_imports_into_methods to 5e5843a