On Sat, Jan 10, 2015 at 4:52 PM, Joachim Durchholz <[email protected]> wrote:

> 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.
>

The other con is that if the function is moved (say, split out into a new
file), you have to change every other file that imports it.

Aaron Meurer


>
>
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CAKgW%3D6JkMd2126JwtYRJhHU-%2BqwRwVHSZtxNEEjGFGBjEjL%3DkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to