From ea3105da1461b37f09bc508bc6b1388e249a581c Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sat, 22 Aug 2015 19:11:56 -0500 Subject: [PATCH 1/4] Backport fix for issue #2560 --- spyderlib/widgets/dicteditorutils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spyderlib/widgets/dicteditorutils.py b/spyderlib/widgets/dicteditorutils.py index 66b7c3e3b24..9aab19d9c16 100644 --- a/spyderlib/widgets/dicteditorutils.py +++ b/spyderlib/widgets/dicteditorutils.py @@ -92,10 +92,10 @@ def address(obj): #----Set limits for the amount of elements in the repr of collections # (lists, dicts, tuples and sets) CollectionsRepr = reprlib.Repr() -CollectionsRepr.maxlist = 1000 -CollectionsRepr.maxdict = 1000 -CollectionsRepr.maxtuple = 1000 -CollectionsRepr.maxset = 1000 +CollectionsRepr.maxlist = 10 +CollectionsRepr.maxdict = 10 +CollectionsRepr.maxtuple = 10 +CollectionsRepr.maxset = 10 #----date and datetime objects support From ac1bd3bbe825b030a2bd77488b4e36ec78b18415 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sat, 22 Aug 2015 19:56:08 -0500 Subject: [PATCH 2/4] Variable Explorer: Put lower limits on when to load data on demand for lists and dicts This was motivated by issue #2593, after noticing people is using those collections to save big DataFrames --- spyderlib/widgets/dicteditor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spyderlib/widgets/dicteditor.py b/spyderlib/widgets/dicteditor.py index 32280ba4bef..890547a197f 100644 --- a/spyderlib/widgets/dicteditor.py +++ b/spyderlib/widgets/dicteditor.py @@ -51,7 +51,7 @@ is_text_string, is_binary_string, getcwd, u) -LARGE_NROWS = 5000 +LARGE_NROWS = 100 def display_to_value(value, default_value, ignore_errors=True): @@ -117,7 +117,7 @@ def __setitem__(self, key, value): class ReadOnlyDictModel(QAbstractTableModel): """DictEditor Read-Only Table Model""" - ROWS_TO_LOAD = 200 + ROWS_TO_LOAD = 50 def __init__(self, parent, data, title="", names=False, truncate=True, minmax=False, remote=False): @@ -1271,9 +1271,9 @@ def setup(self, data, title='', readonly=False, width=500, constant = 121 row_height = 30 error_margin = 20 - height = constant + row_height*min([20, datalen]) + error_margin + height = constant + row_height*min([15, datalen]) + error_margin self.resize(width, height) - + self.setWindowTitle(self.widget.get_title()) if is_text_string(icon): icon = get_icon(icon) From 7d60d907b301aeb544db4cee1dd335c41059f08a Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sat, 22 Aug 2015 20:11:55 -0500 Subject: [PATCH 3/4] Variable Explorer: Don't refresh it after giving focus to it Fixes #2593 --- .../widgets/externalshell/namespacebrowser.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/spyderlib/widgets/externalshell/namespacebrowser.py b/spyderlib/widgets/externalshell/namespacebrowser.py index 42dd2acb16d..56e5aaf80f5 100644 --- a/spyderlib/widgets/externalshell/namespacebrowser.py +++ b/spyderlib/widgets/externalshell/namespacebrowser.py @@ -249,14 +249,23 @@ def option_changed(self, option, value): settings = self.get_view_settings() communicate(self._get_sock(), 'set_remote_view_settings()', settings=[settings]) - + def visibility_changed(self, enable): - """Notify the widget whether its container (the namespace browser + """Notify the widget whether its container (the namespace browser plugin is visible or not""" - self.is_visible = enable - if enable: - self.refresh_table() - + # This is slowing down Spyder a lot if too much data is present in + # the Variable Explorer, and users give focus to it after being hidden. + # This also happens when the Variable Explorer is visible and users + # give focus to Spyder after using another application (like Chrome + # or Firefox). + # That's why we've decided to remove this feature + # Fixes Issue 2593 + # + # self.is_visible = enable + # if enable: + # self.refresh_table() + pass + def toggle_auto_refresh(self, state): """Toggle auto refresh state""" self.autorefresh = state From 5fdca68e4a2e9082aef066843b49921b9f180c42 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sun, 23 Aug 2015 00:28:09 -0500 Subject: [PATCH 4/4] Variable Explorer: Disable auto-refresh after IPython kernel restarts Fixes #2517 --- spyderlib/plugins/ipythonconsole.py | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/spyderlib/plugins/ipythonconsole.py b/spyderlib/plugins/ipythonconsole.py index f8c33afffa8..402440ddd6d 100644 --- a/spyderlib/plugins/ipythonconsole.py +++ b/spyderlib/plugins/ipythonconsole.py @@ -858,7 +858,23 @@ def register_client(self, client, restart=False, give_focus=True): if kernel_widget is None: shellwidget.custom_interrupt_requested.connect( client.interrupt_message) - + + # Connect to our variable explorer + if kernel_widget is not None and self.variableexplorer is not None: + nsb = self.variableexplorer.currentWidget() + # When the autorefresh button is active, our kernels + # start to consume more and more CPU during time + # Fix Issue 1450 + # ---------------- + # When autorefresh is off by default we need the next + # line so that kernels don't start to consume CPU + # Fix Issue 1595 + nsb.auto_refresh_button.setChecked(True) + nsb.auto_refresh_button.setChecked(False) + nsb.auto_refresh_button.setEnabled(False) + nsb.set_ipyclient(client) + client.set_namespacebrowser(nsb) + # If we are restarting the kernel we need to rename # the client tab and do no more from here on if restart: @@ -885,22 +901,6 @@ def register_client(self, client, restart=False, give_focus=True): control.set_inspector_enabled(CONF.get('inspector', 'connect/ipython_console')) - # Connect to our variable explorer - if kernel_widget is not None and self.variableexplorer is not None: - nsb = self.variableexplorer.currentWidget() - # When the autorefresh button is active, our kernels - # start to consume more and more CPU during time - # Fix Issue 1450 - # ---------------- - # When autorefresh is off by default we need the next - # line so that kernels don't start to consume CPU - # Fix Issue 1595 - nsb.auto_refresh_button.setChecked(True) - nsb.auto_refresh_button.setChecked(False) - nsb.auto_refresh_button.setEnabled(False) - nsb.set_ipyclient(client) - client.set_namespacebrowser(nsb) - # Connect client to our history log if self.historylog is not None: self.historylog.add_history(client.history_filename)