Skip to content

Commit 9cbf569

Browse files
committed
src/sage/interfaces/gap.py: don't load all packages on workspace reset
Resetting the GAP workspace already initializes a new Gap instance and loads our default collection of packages. There's no need to load anything else in gap_reset_workspace(). The disabling of the color prompt is now handled in both sage.gaprc and sage.g (both GAP interfaces) so we remove that as well. Fixes: GH-31761
1 parent d42fa25 commit 9cbf569

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

src/sage/interfaces/gap.py

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,17 +1491,11 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
14911491
default when Sage first starts GAP.
14921492
14931493
The first time you start GAP from Sage, it saves the startup state
1494-
of GAP in a file ``$HOME/.sage/gap/workspace-gap-HASH``, where ``HASH``
1495-
is a hash of the directory where Sage is installed.
1496-
1497-
This is useful, since then subsequent startup of GAP is at least 10
1498-
times as fast. Unfortunately, if you install any new code for GAP,
1499-
it won't be noticed unless you explicitly load it, e.g., with
1500-
gap.load_package("my_package")
1501-
1502-
The packages sonata, guava, factint, gapdoc, grape, design, toric,
1503-
and laguna are loaded in all cases before the workspace is saved,
1504-
if they are available.
1494+
of GAP in a file ``$HOME/.sage/gap/workspace-gap-HASH``, where
1495+
``HASH`` is a hash of the directory where Sage is installed. This
1496+
is useful because the subsequent startup of GAP is at least ten
1497+
times as fast. But if you update GAP or any of its packages, those
1498+
changes won't take effect until the workspace is reset.
15051499
15061500
TESTS:
15071501
@@ -1527,19 +1521,9 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
15271521
sage: sage.interfaces.gap.WORKSPACE = ORIGINAL_WORKSPACE
15281522
sage: sage.interfaces.gap.first_try = saved_first_try
15291523
"""
1530-
# Create new workspace with filename WORKSPACE
1524+
# The use_workspace_cache=False causes a new workspace to
1525+
# be created, and we save it immediately thereafter.
15311526
g = Gap(use_workspace_cache=False, max_workspace_size=None)
1532-
g.eval('ColorPrompt(false)')
1533-
g.eval('SetUserPreference("UseColorPrompt", false)')
1534-
g.eval('SetUserPreference("HistoryMaxLines", 30)')
1535-
from sage.tests.gap_packages import all_installed_packages
1536-
for pkg in all_installed_packages(gap=g):
1537-
try:
1538-
g.load_package(pkg, verbose=verbose)
1539-
except RuntimeError as msg:
1540-
if verbose:
1541-
print('*** %s' % msg)
1542-
# end for
15431527
g.save_workspace()
15441528
g.quit()
15451529

0 commit comments

Comments
 (0)