Skip to content
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

Add at_startup flag to lazy_import #14722

Closed
nthiery opened this issue Jun 11, 2013 · 5 comments
Closed

Add at_startup flag to lazy_import #14722

nthiery opened this issue Jun 11, 2013 · 5 comments

Comments

@nthiery
Copy link
Contributor

nthiery commented Jun 11, 2013

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.

CC: @rishikesha @jasongrout @rlmill @mwhansen @simon-king-jena

Component: misc

Author: Nicolas M. Thiéry

Reviewer: Travis Scrimshaw

Merged: sage-5.12.beta1

Issue created by migration from https://trac.sagemath.org/ticket/14722

@nthiery
Copy link
Contributor Author

nthiery commented Jun 11, 2013

@tscrim
Copy link
Collaborator

tscrim commented Jun 21, 2013

comment:2

I'm happy with the patch; are there any objections?

Best,

Travis

@tscrim
Copy link
Collaborator

tscrim commented Jun 27, 2013

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Jun 27, 2013

comment:3

Since there are no objections, I'm setting this to positive review.

@jdemeyer
Copy link
Contributor

Merged: sage-5.12.beta1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants