-
-
Notifications
You must be signed in to change notification settings - Fork 554
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
Import NN directly rather than lazily throughout the Sage library #34652
Comments
comment:1
See #16522 comment:34 for some imports that should be changed. |
comment:2
Something strange is going on. If I make just the change diff --git a/src/sage/rings/semirings/all.py b/src/sage/rings/semirings/all.py
index 9159407408..b150b55ebc 100644
--- a/src/sage/rings/semirings/all.py
+++ b/src/sage/rings/semirings/all.py
@@ -1,6 +1,3 @@
-
-from sage.misc.lazy_import import lazy_import
-lazy_import('sage.rings.semirings.non_negative_integer_semiring',
- ['NonNegativeIntegerSemiring', 'NN'])
+from .non_negative_integer_semiring import NN
from .tropical_semiring import TropicalSemiring then I get a warning upon starting Sage:
Mathematically there is an obvious connection between |
comment:4
With the change above and some other changes (changing imports of NN from sage.rings.semirings.all to the sage.rings.semirings.non_negative_integer_semiring), the startup time may have gone up slightly. I ran |
comment:5
I agree, we should not worry about that increase |
comment:6
Replying to John Palmieri:
The line in
probably explains the link. The semiring class inherits from it and the in fact, as far as I can find, it happens in I suspect the trigger that actually resolves the lazy shim here is |
comment:8
Nils, thanks for the pointer to the lines in Here's a branch. I'm at home working on a slower machine, and I don't see any differences in startup time between this and my Tests might pass, although I just upgraded to the latest MacOS so I am seeing failures. They should be unrelated to these changes. Please test it. New commits:
|
Commit: |
Author: John Palmieri |
comment:9
Okay, if I suppress the warning messages "ld: warning: dylib ... was built for newer macOS version (...) than being linked (...)", then all doctests pass. |
comment:10
The changes from lazy to eager ...
... break a modularization test (sagemath-objects) - see |
comment:11
(sagemath-objects does not ship facade_sets; that could be changed in pkgs/sagemath-objects/MANIFEST.in, pkgs/sagemath-categories/MANIFEST.in.m4 if necessary.) |
comment:12
We could also try the import and |
comment:13
I think adding facade_sets to sagemath-objects is well motivated; facade parents are an aspect of the parent/element framework. However, I wouldn't like to do the same change with metric_spaces. |
comment:14
I don't mind changing the |
comment:16
(Not sure if I made the right changes to the manifests.) |
comment:17
LGTM, let's wait for the Build&Test action |
Reviewer: Matthias Koeppe |
comment:19
Thanks! |
Changed branch from u/jhpalmieri/trac34652-actively-import-NN to |
This is extracted from #16522.
One issue raised on that ticket is that it is problematic to use lazy imports on things other than a function (stated in #16522 comment:20). It appears that using honest imports rather than lazy ones for
NN
should not cause too much of a slowdown, but this needs to be tested.CC: @nbruin @mkoeppe
Component: misc
Author: John Palmieri
Branch/Commit:
539119b
Reviewer: Matthias Koeppe
Issue created by migration from https://trac.sagemath.org/ticket/34652
The text was updated successfully, but these errors were encountered: