Skip to content

Make cvxpy import lazy #1606

@wshanks

Description

@wshanks

Suggested feature

Here is what I get from python -Ximporttime test.py with this file:

import qiskit_experiments
  • 4.9 sec total import time
  • 1.2 sec to import lmfit (which is mostly importing scipy and matplotlib)
  • 0.7 sec to import qiskit_ibm_experiment (which is mostly pandas, and a little requests and requests_ntlm)
  • 0.7 sec to import qiskit (0.16 for numpy, the rest mostly internal)
  • 0.6 sec to import qiskit-ibm-runtime (half internal, with 0.07 for pydantic, 0.07 for qiskit_aer, and 0.17 for ibm_platform_services and ibm_cloud_sdk_core)
  • 0.86 for cvxpy

While I think it is hard to avoid importing qiskit and qiskit-ibm-runtime and also hard to import lmfit (even doing that scipy and matplotlib would probably get imported elsewhere) and so not worth deferring them, I think it should be pretty easy to delay importing cvxpy. qiskit-ibm-experiment is already covered in #1599 but even so we'd probably end up importing pandas and requests any way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions