Skip to content

Avoid useless imports #180

Description

@yguclu

Problem Description

Importing modules from SymPDE is slow and should be speeded up.

One of the reasons is that some of our modules import lots of code from third-party libraries, which is not needed in most cases. For example, file sympde/utilities/utils.py starts with

import numpy as np
import itertools as it
from sympy import lambdify


from mpl_toolkits.mplot3d import *
import matplotlib.pyplot as plt

where the 3D matplotlib imports are only needed by the plot function plot_3d in the module, and not by lambdify_sympde. Moreover, there is no need to import everything with import *.

Suggested Solution

  • Do not use: from ... import *
  • Move slow imports into function definition

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions