E.g. some modules do
from sympy import log
others do
from sympy.functions.elementary.exponential import exp
Pros of doing just direct imports
---------------------------------
01) Code review can instantly see where some symbol originates from.
02) This should eliminate some circular imports.
Cons
----
11) The import block gets longer.
Neutral aspects
---------------
21) If indirect imports are to be banned from SymPy's codebase as a
matter of code style: This can be checked using an import diagnostics
tool that's mostly done already (I'm working on it, a very old and
outdated prototype can be found in bin/diagnose_imports).
22) Contributors might not want to have to hunt down the origin of every
symbol that they want to import.
The good news is that if they import from some other module than the one
that defines the name, they'll get a message that tells them where to
import from directly.
E.g. this:
--
Error in $SYMPY/sympy/series/tests/test_limits.py line 3: Name 'log'
should be imported from module 'sympy.functions.elementary.exponential'
but is imported from module 'sympy'.
--
23) No doctest checking.
I think this could be made to work, but IMHO doctests are examples how
SymPy users should use it, and they should import from sympy instead of
from the module where the implementation of a name happens to live, so
import diagnostics on doctest code would be a bad idea anyway.
Final question
--------------
Do we want to forbid indirect imports inside the sympy/ directory, as a
matter of code style?
Why I ask this now
------------------
I'm currently testing my import diagnostics tool, and there are so many
indirect imports that they tend to drown out the interesting messages.
If indirect imports are going to go away anyway, I can cut down on them
and commit that even before I do the PR for the tool.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/54B1AD47.2030100%40durchholz.org.
For more options, visit https://groups.google.com/d/optout.