perf: load matplotlib on-demand
it takes ~1.7 seconds to import electrum.plot, slowing down app-startup considerably
This commit is contained in:
@@ -61,12 +61,6 @@ if TYPE_CHECKING:
|
||||
_logger = get_logger(__name__)
|
||||
|
||||
|
||||
try:
|
||||
from electrum.plot import plot_history, NothingToPlotException
|
||||
except:
|
||||
_logger.info("could not import electrum.plot. This feature needs matplotlib to be installed.")
|
||||
plot_history = None
|
||||
|
||||
# note: this list needs to be kept in sync with another in kivy
|
||||
TX_ICONS = [
|
||||
"unconfirmed.png",
|
||||
@@ -631,10 +625,15 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
||||
d.exec_()
|
||||
|
||||
def plot_history_dialog(self):
|
||||
if plot_history is None:
|
||||
try:
|
||||
from electrum.plot import plot_history, NothingToPlotException
|
||||
except Exception as e:
|
||||
_logger.error(f"could not import electrum.plot. This feature needs matplotlib to be installed. exc={e!r}")
|
||||
self.parent.show_message(
|
||||
_("Can't plot history.") + '\n' +
|
||||
_("Perhaps some dependencies are missing...") + " (matplotlib?)")
|
||||
_("Perhaps some dependencies are missing...") + " (matplotlib?)" + '\n' +
|
||||
f"Error: {e!r}"
|
||||
)
|
||||
return
|
||||
try:
|
||||
plt = plot_history(list(self.hm.transactions.values()))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# note: This module takes 1-2 seconds to import. It should be imported *on-demand*.
|
||||
|
||||
import datetime
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
Reference in New Issue
Block a user