-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interfaces: use more lazy imports, restore top-level functions maxima_console etc. #34547
Comments
comment:1
+1 |
Commit: |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:4
Here is a first attempt. I'll mark it as ready for review, but I am certainly open to changes. If I made changes for the imports for |
comment:5
Regarding the change
Do we need to deprecate this before just removing it? I don't know what purpose it was supposed to serve, except perhaps it is the remnants of some old code that once looped through it. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
This comment has been minimized.
This comment has been minimized.
comment:8
Where do the ".all" namespaces actually get used and for what? Are they just to trigger initialization of modules? Or do people use them to access symbols too? They certainly be importing symbols from them. Especially with lazy imports, that leads to undesirable side-effects (see e.g. #16522):
So as you can see, we end up with a The delayed instantiation of interfaces is laudable but, as you can see, can introduce new problems. What does work is lazy importing the object where you need it, but I'm not so sure we need these objects at the 'all' level. Certainly the |
comment:9
Replying to Nils Bruin:
|
comment:10
Right now, |
comment:11
Maybe we need to keep the one in |
comment:12
Replying to Matthias Köppe:
Ah, OK, so our current infrastructure actually guarantees that One reason to ensure
versus
Note:
|
comment:13
Replying to Nils Bruin:
Thanks for the pointer to #16522. I haven't looked at the details, but this sounds promising. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:15
Is this branch okay, or do we need to do something to accommodate #16522? |
comment:16
Are these changes:
needed because of #16522? |
comment:17
I see the following with this branch:
I don't understand why this change is necessary. |
comment:18
Maybe it is #16522. |
comment:19
Yes, I think this should be solved via #16522 instead of working around it in the doctests |
Dependencies: #16522 |
comment:20
I don't think #16522 will prevent this problem: I don't think special methods like This is why most slot methods are separately wrapped to trigger resolution, because these would never fail. |
comment:21
The |
comment:48
One of the failures can be avoided by deleting the loop variable |
comment:49
Oh, I see, we can just move |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:51
This works for me. |
Changed branch from u/jhpalmieri/lazy_imports_for_interfaces to |
Changed commit from |
comment:54
Followup at #34927: a change to a doctest for |
comment:55
More issues: I have no idea why, but removing these lines from interfaces.all break the emacs sage-shell-mode:
If I restore this, or if I just add a line I thought that this might be related to
Do we care? Is it worth restoring these? |
comment:56
This line seems to refer to this global Sage variable -- https://github.com/sagemath/sage-shell-mode/blob/master/emacs_sage_shell.py#L55 |
comment:57
Thank you for finding that. I do enjoy reading uncommented code... |
comment:58
This variable is not used anywhere in the Sage library, as far as I can tell. I see three options:
1 is easiest. 2 makes more sense than 1, and 3 makes more sense than 2, at least to me. Unless we think that other people were also using this variable? |
comment:59
To spell out the easy solution: diff --git a/src/sage/interfaces/all.py b/src/sage/interfaces/all.py
index 92e19e3d38..53cf7c92dd 100644
--- a/src/sage/interfaces/all.py
+++ b/src/sage/interfaces/all.py
@@ -43,3 +43,9 @@ 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')
+
+# The following variable is used by sage-shell-mode in emacs:
+interfaces = ['gap', 'gap3', 'giac', 'gp', 'mathematica', 'gnuplot', \
+ 'kash', 'magma', 'macaulay2', 'maple', 'maxima', \
+ 'mathematica', 'mwrank', 'octave', 'r', \
+ 'singular', 'sage0', 'sage'] |
comment:60
Yes, I think that's a good solution, at least for now. |
comment:61
Done in #34935. |
It turns out that sage-shell-mode in emacs uses the variable `interfaces`, deleted from `sage.interfaces.all` in #34547. We restore that variable (which is not used anywhere in the Sage library) along with a comment. URL: https://trac.sagemath.org/34935 Reported by: jhpalmieri Ticket author(s): John Palmieri Reviewer(s): Matthias Koeppe
Fix interfaces/fricas.py doctest failure. Followup to #34547.
This is a followup to #34547, making changes similar to ones already made there. URL: https://trac.sagemath.org/34927 Reported by: jhpalmieri Ticket author(s): John Palmieri Reviewer(s): Matthias Koeppe
Various files in
sage/interfaces/
have this pattern:When combined with
from .octave import Octave, octave
insage/interfaces/all.py
, this means that an instance ofOctave
is created when Sage starts up. I think we should avoid this with lazy imports.Depends on #16522
Component: interfaces
Author: John Palmieri
Branch:
09f5d92
Reviewer: Matthias Koeppe
Issue created by migration from https://trac.sagemath.org/ticket/34547
The text was updated successfully, but these errors were encountered: