Skip to content

Commit 0f7314d

Browse files
author
Release Manager
committed
gh-35275: Drinfeld modules: Make some imports lazy <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> ### 📚 Description <!-- Describe your changes here in detail --> We replace some `import`s by `lazy_imports` in `sage.categories.drinfeld_modules` and make the import of `DrinfeldModule` into the global namespace lazy. We also move the module-level import of `PolynomialBaseringInjection` in `sage.rings.polynomial.polynomial_ring` into a method. <!-- Why is this change required? What problem does it solve? --> `git grep '^from sage.rings' src/sage/categories` reveals that the recently added `.drinfeld_modules` is the only module that imports nontrivial things from `sage.rings`. This is a new obstacle to modularization (it caused an error due to import cycles in #35095.) The purpose of reducing the module-level import to a method-level import is explained in https://doc.sagemath.org/html/en/developer/packaging_sag e_library.html#module-level-runtime-dependencies <!-- If it resolves an open issue, please link to the issue here. For example "Closes #1337" --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have made sure that the title is self-explanatory and the description concisely explains the PR. - [ ] I have linked an issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open pull requests that this PR logically depends on --> <!-- - #xyz: short description why this is a dependency - #abc: ... --> URL: #35275 Reported by: Matthias Köppe Reviewer(s): Antoine Leudière, Matthias Köppe
2 parents db57bd3 + 72111c6 commit 0f7314d

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/sage/categories/drinfeld_modules.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
from sage.categories.homsets import Homsets
2424
from sage.misc.functional import log
2525
from sage.misc.latex import latex
26+
from sage.misc.lazy_import import lazy_import
2627
from sage.rings.integer import Integer
27-
from sage.rings.polynomial.ore_polynomial_ring import OrePolynomialRing
28-
from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
29-
from sage.rings.ring_extension import RingExtension_generic
28+
29+
lazy_import('sage.rings.polynomial.ore_polynomial_ring', 'OrePolynomialRing')
30+
lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_general')
31+
lazy_import('sage.rings.ring_extension', 'RingExtension_generic')
3032

3133

3234
class DrinfeldModules(Category_over_base_ring):
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
from .constructor import FunctionField
2-
from .drinfeld_modules.drinfeld_module import DrinfeldModule
2+
3+
from sage.misc.lazy_import import lazy_import
4+
5+
lazy_import("sage.rings.function_field.drinfeld_modules.drinfeld_module", "DrinfeldModule")

src/sage/rings/polynomial/polynomial_ring.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@
166166
import sage.rings.abc
167167
from sage.rings.fraction_field_element import FractionFieldElement
168168
from sage.rings.finite_rings.element_base import FiniteRingElement
169-
170-
from .polynomial_element import PolynomialBaseringInjection
171169
from .polynomial_real_mpfr_dense import PolynomialRealDense
172170
from .polynomial_integer_dense_flint import Polynomial_integer_dense_flint
173171
from sage.rings.polynomial.polynomial_singular_interface import PolynomialRing_singular_repr
@@ -679,6 +677,8 @@ def _coerce_map_from_base_ring(self):
679677
To: Univariate Polynomial Ring in x over Rational Field
680678
sage: R.coerce_map_from(GF(7))
681679
"""
680+
from .polynomial_element import PolynomialBaseringInjection
681+
682682
return PolynomialBaseringInjection(self.base_ring(), self)
683683

684684
def _coerce_map_from_(self, P):

0 commit comments

Comments
 (0)