#10906: lazy import can break unique representation
-----------------------+----------------------------------------------------
Reporter: nthiery | Owner: jason
Type: defect | Status: new
Priority: major | Milestone:
Component: misc | Keywords: lazy import, unique representation
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
-----------------------+----------------------------------------------------
Comment(by nthiery):
Replying to [comment:3 robertwb]:
> Lazy import are mostly used to avoid importing expensive modules
> when you might want to use their functionality. It would be both
> inefficient and messy to use at a fine-graned level. Whole modules
> are nice to lazily import.
> As for the basic objects like ZZ, QQ, CC, etc. there's no reason to
> lazily import them, as those modules will always be already
> loaded.
Well, except for category code, especially in the basic categories!
And that's precisely where lazy importation is a nice idiom, since
this code is loaded very early and one does not want to cause loops
there. But lazy importing the appropriate modules instead will indeed
work too. Thanks for the tip.
Now, to avoid getting confused in case of misuse (which can lead to
very tricky situations to debug), what about changing the repr for
lazy imported object so that one would get something like:
{{{
sage: lazy_import('sage.all', 'ZZ', 'my_ZZ')
sage: def bla(x = my_ZZ):
... return x
sage: bla()
Lazy import of Integer Ring
sage: bla() is ZZ
False
sage: bla()(1)
1
sage: bla() is ZZ
False
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10906#comment:4>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.