#14187: Check that lazy imports are not resolved during startup
--------------------------------+-------------------------------------------
Reporter: vbraun | Owner: tbd
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.8
Component: performance | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers: Nicolas M. ThiƩry
Authors: Volker Braun | Merged in:
Dependencies: | Stopgaps:
--------------------------------+-------------------------------------------
Comment (by nthiery):
Hi Volker!
Thanks for the updated patch! I am almost ready to put it a positive
review. Just one thing about the import of NN in
sage/combinat/integer_vectors_mod_permgroup.py: I think one should
repeat the lazy import there rather than importing from {{{all}}}
where it's lazy imported. Otherwise, lazy import misses information to
complete its job.
Quick example: in a file all.py, put:
{{{
from sage.misc.lazy_import import lazy_import
lazy_import('sage.rings.semirings.non_negative_integer_semiring', 'NN')
}}}
and in blah.py:
{{{
import all
from all import NN
print type(all.NN)
print type(NN)
NN(1)
print type(all.NN)
print type(NN)
}}}
With those we get:
{{{
sage: import blah
<type 'sage.misc.lazy_import.LazyImport'>
<type 'sage.misc.lazy_import.LazyImport'>
<class
'sage.rings.semirings.non_negative_integer_semiring.NonNegativeIntegerSemiring_with_category'>
<type 'sage.misc.lazy_import.LazyImport'>
}}}
Interpretation: upon using NN, lazy import substitutes the lazy import
object by NN in the module where it was lazy imported. But not in
blah! And that won't happen either if use explicitly the NN from blah:
{{{
sage: blah.NN
Non negative integer semiring
sage: type(blah.NN)
sage.misc.lazy_import.LazyImport
sage: blah.NN(1)
1
sage: type(blah.NN)
sage.misc.lazy_import.LazyImport
}}}
Btw, you may want to write the output description in is_during_startup
as {{{OUTPUT: a boolean}}}, but that's more a question of taste.
Cheers,
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14187#comment:13>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.