#16520: circular import in maxima_lib.py
-------------------------------------+-------------------------------------
Reporter: rws | Owner:
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.3
Component: interfaces | Resolution:
Keywords: maxima, cleanup | Merged in:
Authors: Ralf Stephan | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/rws/circular_import_in_maxima_lib_py|
a3bc86c0855155e2755f9174f95f8dd578827d92
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nbruin):
I noticed these executed at runtime (as opposed to module initialization
time):
{{{
+ from sage.rings.rational import Rational
+ from sage.rings.number_field.number_field_element_quadratic import
NumberFieldElement_quadratic
+ if isinstance(obj, Rational):
}}}
That's bad, because these are global assignments. You don't want to do
those
again and again. Also, I find it hard to believe that those two modules
somehow
refer back to `maxima_lib`.
The following runs at module initialization time anyway. I don't see how
`from
...` makes this better than `import sage.symbolic.pynac`. It's not
critical, so
I don't really care, apart from the fact that the namespace gets an extra
unnecessary symbol `symbol_table`.
{{{
+from sage.symbolic.pynac import symbol_table
+max_to_pynac_table = symbol_table['maxima']
}}}
In general, I have trouble seeing how `maxima_lib` can lead to circular
imports,
because `maxima_lib` is an interface and as such gets referenced by
virtually
no-one. The only place is `sage.calculus.calculus` and I've very carefully
made
sure we don't reference that. Furthermore, even there it's imported
lazily, and
for very good reason: Importing `maxima_lib` initializes `ecl` with
`maxima`
which takes considerable time.
So I suspect it's not so much a circular import but a bad interaction
between
the lazy import of `maxima_lib` and the attempted lazy import of
`hypergeometric`. The proper solution is probably to *not* lazily import
hypergeometric into maxima_lib, but import it plainly there. By the time
you're
importing maxima_lib you're already committed to significant
initialization
time, so unless hypergeometric does something really strange, I don't
expect it
will have a significant effect.
TL;DR: I'm not convinced that this ticket is actually solving a real
problem.
--
Ticket URL: <http://trac.sagemath.org/ticket/16520#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 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.
For more options, visit https://groups.google.com/d/optout.