sagemath/sage

sage.misc.latex, sage.repl.display.fancy_repr: Make imports more local

Closed this issue · 10 comments

(cherry-picked from #32432)

CC: @mwageringel @kwankyu

Component: refactoring

Author: Matthias Koeppe

Branch/Commit: bdd0325

Reviewer: Kwankyu Lee

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

Commit: bdd0325

Author: Matthias Koeppe

New commits:

22f125bsrc/sage/misc/latex.py: Move import from sage.misc.sage_eval into method
0809840src/sage/misc/latex.py: Move import of have_program into methods
bdd0325sage.repl.display.fancy_repr: For isinstance testing, import abc Matrix from sage.structure.element
comment:4

What is the rationale of moving module-level import of have_program to function level?

comment:5

Most modules that import from sage.misc.latex only import the latex function, which does not actually need to run any program; so removing this module-level import removes the indirect dependency on sage.misc.ostools (and hence on CPython- and Unix-specific code).

comment:6

Replying to @mkoeppe:

Most modules that import from sage.misc.latex only import the latex function, which does not actually need to run any program; so removing this module-level import removes the indirect dependency on sage.misc.ostools (and hence on CPython- and Unix-specific code).

If we need to care of these dependency issues because of the modularization effort, it might be useful to have a patchbot plugin to watch out increase of dependency among sage modules.

Reviewer: Kwankyu Lee

comment:7

Thanks for the review.

Yes, testing infrastructure for this is in the works - see #32432