From 250da03c8602100d6df6b405e23ded5644bdc217 Mon Sep 17 00:00:00 2001 From: "John H. Palmieri" Date: Sat, 17 Sep 2022 11:41:44 -0700 Subject: [PATCH 1/2] trac 34547: use lazy imports in much of sage.interfaces.all --- src/sage/interfaces/all.py | 78 +++++++++++++++----------------- src/sage/interfaces/axiom.py | 2 +- src/sage/interfaces/giac.py | 2 +- src/sage/interfaces/kash.py | 2 +- src/sage/interfaces/lie.py | 2 +- src/sage/interfaces/lisp.py | 2 +- src/sage/interfaces/macaulay2.py | 2 +- src/sage/interfaces/magma.py | 1 + src/sage/interfaces/maple.py | 2 +- src/sage/interfaces/mupad.py | 2 +- src/sage/interfaces/mwrank.py | 2 +- src/sage/interfaces/octave.py | 2 +- 12 files changed, 48 insertions(+), 51 deletions(-) diff --git a/src/sage/interfaces/all.py b/src/sage/interfaces/all.py index 73d032ff518..f67cab4dfcc 100644 --- a/src/sage/interfaces/all.py +++ b/src/sage/interfaces/all.py @@ -1,52 +1,48 @@ # interfaces to other interpreters -from sage.misc.lazy_import import lazy_import - -from .frobby import frobby -from .four_ti_2 import four_ti_2 -from .axiom import Axiom, axiom -from .fricas import FriCAS, fricas - +from .sage0 import sage0, sage0_version, Sage from .gap import gap, gap_reset_workspace, Gap -from .gap3 import gap3, gap3_version, Gap3 -lazy_import('sage.interfaces.genus2reduction', ['genus2reduction', 'Genus2reduction']) -from .gfan import gfan, Gfan -from .giac import giac, Giac from .gp import gp, gp_version, Gp -from .gnuplot import gnuplot -from .kash import kash, kash_version, Kash -from .lisp import lisp, Lisp -from .magma import magma, Magma -from .magma_free import magma_free -from .macaulay2 import macaulay2, Macaulay2 -from .maple import maple, Maple -from .maxima import maxima, Maxima # import problems #from maxima_lib import maxima_lib -from .mathematica import mathematica, Mathematica -from .mathics import mathics, Mathics -from .matlab import matlab, matlab_version, Matlab -from .mupad import mupad, Mupad # NOT functional yet -from .mwrank import mwrank, Mwrank -from .octave import octave, Octave -from .polymake import polymake -from .qepcad import qepcad, qepcad_version, qepcad_formula -from .qsieve import qsieve +from .maxima import maxima, Maxima from .singular import singular, singular_version, Singular -from .sage0 import sage0 as sage0, sage0_version, Sage -from .scilab import scilab -from .tachyon import tachyon_rt -from .psage import PSage -from .ecm import ECM, ecm -from .povray import povray -from .lie import lie, LiE -from .r import r, R, r_version -from .read_data import read_data -interfaces = ['gap', 'gap3', 'giac', 'gp', 'mathematica', 'gnuplot', \ - 'kash', 'magma', 'macaulay2', 'maple', 'maxima', \ - 'mathematica', 'mwrank', 'octave', 'r', \ - 'singular', 'sage0', 'sage'] +from .magma import magma, Magma +from .polymake import polymake + +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.interfaces.axiom', ['Axiom', 'axiom']) +lazy_import('sage.interfaces.ecm', ['ECM', 'ecm']) +lazy_import('sage.interfaces.four_ti_2', 'four_ti_2') +lazy_import('sage.interfaces.fricas', ['FriCAS', 'fricas']) +lazy_import('sage.interfaces.frobby', 'frobby') +lazy_import('sage.interfaces.gap3', ['gap3', 'gap3_version', 'Gap3']) +lazy_import('sage.interfaces.genus2reduction', ['genus2reduction', 'Genus2reduction']) +lazy_import('sage.interfaces.gfan', ['gfan', 'Gfan']) +lazy_import('sage.interfaces.giac', ['giac', 'Giac']) +lazy_import('sage.interfaces.gnuplot', 'gnuplot') +lazy_import('sage.interfaces.kash', ['kash', 'kash_version', 'Kash']) +lazy_import('sage.interfaces.lie', ['lie', 'LiE']) +lazy_import('sage.interfaces.lisp', ['lisp', 'Lisp']) +lazy_import('sage.interfaces.macaulay2', ['macaulay2', 'Macaulay2']) +lazy_import('sage.interfaces.magma_free', 'magma_free') +lazy_import('sage.interfaces.maple', ['maple', 'Maple']) +lazy_import('sage.interfaces.mathematica', ['mathematica', 'Mathematica']) +lazy_import('sage.interfaces.mathics', ['mathics', 'Mathics']) +lazy_import('sage.interfaces.matlab', ['matlab', 'matlab_version', 'Matlab']) +lazy_import('sage.interfaces.mupad', ['mupad', 'Mupad']) # NOT functional yet +lazy_import('sage.interfaces.mwrank', ['mwrank', 'Mwrank']) +lazy_import('sage.interfaces.octave', ['octave', 'Octave']) +lazy_import('sage.interfaces.povray', 'povray') +lazy_import('sage.interfaces.psage', 'PSage') +lazy_import('sage.interfaces.qepcad', ['qepcad', 'qepcad_version', 'qepcad_formula']) +lazy_import('sage.interfaces.qsieve', 'qsieve') +lazy_import('sage.interfaces.r', ['r', 'R', 'r_version']) +lazy_import('sage.interfaces.read_data', 'read_data') +lazy_import('sage.interfaces.scilab', 'scilab') +lazy_import('sage.interfaces.tachyon', 'tachyon_rt') try: from sage.repl.rich_output.display_manager import get_display_manager as _get_display_manager diff --git a/src/sage/interfaces/axiom.py b/src/sage/interfaces/axiom.py index 499592bae6a..68fdb46c64a 100644 --- a/src/sage/interfaces/axiom.py +++ b/src/sage/interfaces/axiom.py @@ -490,7 +490,7 @@ def __reduce__(self): """ EXAMPLES:: - sage: axiom.__reduce__() + sage: Axiom().__reduce__() (, ()) sage: f, args = _ sage: f(*args) diff --git a/src/sage/interfaces/giac.py b/src/sage/interfaces/giac.py index 87ff828edec..a218607ffd1 100644 --- a/src/sage/interfaces/giac.py +++ b/src/sage/interfaces/giac.py @@ -371,7 +371,7 @@ def __reduce__(self): """ EXAMPLES:: - sage: giac.__reduce__() + sage: Giac().__reduce__() (, ()) sage: f, args = _ sage: f(*args) diff --git a/src/sage/interfaces/kash.py b/src/sage/interfaces/kash.py index ce837b87737..81b0b79d599 100644 --- a/src/sage/interfaces/kash.py +++ b/src/sage/interfaces/kash.py @@ -673,7 +673,7 @@ def _function_call_string(self, function, args, kwds): EXAMPLES:: - sage: kash._function_call_string('Expand', ['x', 'y'], ['Prec:=10']) + sage: Kash()._function_call_string('Expand', ['x', 'y'], ['Prec:=10']) 'Expand(x,y,rec(Prec:=10))' """ if not kwds: diff --git a/src/sage/interfaces/lie.py b/src/sage/interfaces/lie.py index 3d3a0ded886..13f2bd33814 100644 --- a/src/sage/interfaces/lie.py +++ b/src/sage/interfaces/lie.py @@ -474,7 +474,7 @@ def __reduce__(self): """ EXAMPLES:: - sage: lie.__reduce__() + sage: LiE().__reduce__() (, ()) """ return reduce_load_lie, tuple([]) diff --git a/src/sage/interfaces/lisp.py b/src/sage/interfaces/lisp.py index 0f9d09605bf..d2093eee0a4 100644 --- a/src/sage/interfaces/lisp.py +++ b/src/sage/interfaces/lisp.py @@ -220,7 +220,7 @@ def __reduce__(self): """ EXAMPLES:: - sage: lisp.__reduce__() + sage: Lisp().__reduce__() (, ()) """ return reduce_load_Lisp, tuple([]) diff --git a/src/sage/interfaces/macaulay2.py b/src/sage/interfaces/macaulay2.py index 91e4da97ea0..0348600855c 100644 --- a/src/sage/interfaces/macaulay2.py +++ b/src/sage/interfaces/macaulay2.py @@ -237,7 +237,7 @@ def __reduce__(self): EXAMPLES:: - sage: rlm2, t = macaulay2.__reduce__() + sage: rlm2, t = Macaulay2().__reduce__() sage: rlm2(*t) Macaulay2 """ diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py index bd75a6a1850..1460eb5d6ac 100644 --- a/src/sage/interfaces/magma.py +++ b/src/sage/interfaces/magma.py @@ -566,6 +566,7 @@ def _preparse(self, s): EXAMPLES:: + sage: magma = Magma() sage: magma._preparse_colon_equals = False sage: magma._preparse('a = 5') 'a = 5' diff --git a/src/sage/interfaces/maple.py b/src/sage/interfaces/maple.py index b3818b73dec..e32622a0ffe 100644 --- a/src/sage/interfaces/maple.py +++ b/src/sage/interfaces/maple.py @@ -337,7 +337,7 @@ def __reduce__(self): """ EXAMPLES:: - sage: maple.__reduce__() + sage: Maple().__reduce__() (, ()) sage: f, args = _ sage: f(*args) diff --git a/src/sage/interfaces/mupad.py b/src/sage/interfaces/mupad.py index ada87034c0c..bec52480111 100644 --- a/src/sage/interfaces/mupad.py +++ b/src/sage/interfaces/mupad.py @@ -147,7 +147,7 @@ def __reduce__(self): """ EXAMPLES:: - sage: mupad.__reduce__() + sage: Mupad().__reduce__() (, ()) """ diff --git a/src/sage/interfaces/mwrank.py b/src/sage/interfaces/mwrank.py index dd4663ab802..f964285cfd1 100644 --- a/src/sage/interfaces/mwrank.py +++ b/src/sage/interfaces/mwrank.py @@ -210,7 +210,7 @@ def __reduce__(self): """ EXAMPLES:: - sage: mwrank.__reduce__() + sage: Mwrank().__reduce__() (, ()) """ diff --git a/src/sage/interfaces/octave.py b/src/sage/interfaces/octave.py index 4923aec71da..23ea8cb2a5e 100644 --- a/src/sage/interfaces/octave.py +++ b/src/sage/interfaces/octave.py @@ -225,7 +225,7 @@ def __reduce__(self): """ EXAMPLES:: - sage: octave.__reduce__() + sage: Octave().__reduce__() (, ()) """ return reduce_load_Octave, tuple([]) From 9566546fec29409bb5d700275495720b224cfa01 Mon Sep 17 00:00:00 2001 From: "John H. Palmieri" Date: Sun, 18 Sep 2022 13:09:33 -0700 Subject: [PATCH 2/2] trac 34547: remove two "import sage.interfaces.all" lines --- src/sage/rings/finite_rings/integer_mod.pyx | 2 -- src/sage/rings/finite_rings/integer_mod_ring.py | 1 - 2 files changed, 3 deletions(-) diff --git a/src/sage/rings/finite_rings/integer_mod.pyx b/src/sage/rings/finite_rings/integer_mod.pyx index 400bf154522..ae9d56c5e35 100644 --- a/src/sage/rings/finite_rings/integer_mod.pyx +++ b/src/sage/rings/finite_rings/integer_mod.pyx @@ -91,8 +91,6 @@ from sage.libs.pari.all import pari, PariError import sage.rings.integer_ring as integer_ring import sage.rings.rational_field -import sage.interfaces.all - import sage.rings.integer cimport sage.rings.integer from sage.rings.integer cimport Integer diff --git a/src/sage/rings/finite_rings/integer_mod_ring.py b/src/sage/rings/finite_rings/integer_mod_ring.py index 12c3c71c5ba..90ed5965c27 100644 --- a/src/sage/rings/finite_rings/integer_mod_ring.py +++ b/src/sage/rings/finite_rings/integer_mod_ring.py @@ -72,7 +72,6 @@ from sage.libs.pari.all import pari, PariError -import sage.interfaces.all from sage.misc.cachefunc import cached_method from sage.structure.factory import UniqueFactory