Opened 9 years ago
Closed 9 years ago
#14722 closed enhancement (fixed)
Add at_startup flag to lazy_import
Reported by: | nthiery | Owned by: | jason |
---|---|---|---|
Priority: | major | Milestone: | sage-5.12 |
Component: | misc | Keywords: | |
Cc: | rishi, jason, rlm, mhansen, SimonKing | Merged in: | sage-5.12.beta1 |
Authors: | Nicolas M. Thiéry | Reviewers: | Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Lazy imports have two main use cases: (a) Delaying imports that are not always needed for a faster Sage startup (b) Resolving import loops
This ticket introduce an option "at_startup" to allow for lazy imports that are known to be resolved at startup time. The main use case is (b) in the context of #10963. E.g. the categories Magmas and Semigroups import each other reciprocally (because Magmas.Associative points to Semigroups). It is natural to resolve this by defining Magmas.Associative using a lazy import; one can then play with Magmas() without having to load Semigroups. However Semigroups() is later constructed during Sage's startup (and this is unlikely to change).
This option could also be used as an intermediate step toward (a), when a module is used in several places and some of those places can already afford to lazy import the module but not yet others. As a bonus, a lazy import that is marked as "at_startup" will print a message if it is actually resolved after the startup, so that the developer know that (s)he can remove the flag.
Attachments (1)
Change History (6)
Changed 9 years ago by
comment:1 Changed 9 years ago by
- Cc rishi jason rlm mhansen SimonKing added; sage-combinat removed
- Status changed from new to needs_review
comment:2 Changed 9 years ago by
comment:3 Changed 9 years ago by
- Reviewers set to Travis Scrimshaw
- Status changed from needs_review to positive_review
Since there are no objections, I'm setting this to positive review.
comment:4 Changed 9 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:5 Changed 9 years ago by
- Merged in set to sage-5.12.beta1
- Resolution set to fixed
- Status changed from positive_review to closed
I'm happy with the patch; are there any objections?
Best,
Travis