Skip to content

Commit da6e808

Browse files
authored
Merge pull request #25028 from CAM-Gerlach/console-confpage-increase-buffer
PR: Increase default max console buffer and warn if it's big (IPython console)
2 parents 697f4c7 + 800b726 commit da6e808

File tree

2 files changed

+59
-23
lines changed

2 files changed

+59
-23
lines changed

spyder/config/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
'show_calltips': True,
161161
'ask_before_closing': False,
162162
'show_reset_namespace_warning': True,
163-
'buffer_size': 500,
163+
'buffer_size': 5000,
164164
'pylab': True,
165165
'pylab/autoload': False,
166166
'pylab/backend': 'inline',
@@ -721,4 +721,4 @@
721721
# or if you want to *rename* options, then you need to do a MAJOR update in
722722
# version, e.g. from 3.0.0 to 4.0.0
723723
# 3. You don't need to touch this value if you're just adding a new option
724-
CONF_VERSION = '87.4.0'
724+
CONF_VERSION = '87.5.0'

spyder/plugins/ipythonconsole/confpage.py

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111

1212
# Third party imports
1313
from qtpy.QtCore import Qt
14-
from qtpy.QtWidgets import (QGridLayout, QGroupBox, QHBoxLayout, QLabel,
15-
QVBoxLayout)
14+
from qtpy.QtWidgets import (
15+
QGridLayout,
16+
QGroupBox,
17+
QHBoxLayout,
18+
QLabel,
19+
QMessageBox,
20+
QVBoxLayout,
21+
)
1622

1723
# Local imports
1824
from spyder.api.translations import _
@@ -21,6 +27,12 @@
2127

2228
class IPythonConsoleConfigPage(PluginConfigPage):
2329

30+
def __init__(self, plugin, parent):
31+
super().__init__(plugin, parent)
32+
33+
self.buffer_spin = None
34+
self.apply_callback = self.warn_if_large_buffer
35+
2436
def setup_page(self):
2537
newcb = self.create_checkbox
2638

@@ -42,7 +54,7 @@ def setup_page(self):
4254
'show_elapsed_time',
4355
tip=_("Display the time since the current console was started "
4456
"in the tab bar"),
45-
)
57+
)
4658

4759
display_layout = QVBoxLayout()
4860
display_layout.addWidget(banner_box)
@@ -118,21 +130,19 @@ def setup_page(self):
118130

119131
# Output group
120132
output_group = QGroupBox(_("Output"))
121-
122-
# Note: The maximum here is set to a relatively small value because
123-
# larger ones make Spyder sluggish.
124-
# Fixes spyder-ide/spyder#19091
125-
buffer_spin = self.create_spinbox(
133+
self.buffer_spin = self.create_spinbox(
126134
_("Buffer:"),
127135
_(" lines"),
128136
'buffer_size',
129-
min_=-1,
130-
max_=5000,
137+
min_=100,
138+
# >10k can make Spyder slow, see spyder-ide/spyder#19091
139+
max_=50_000,
131140
step=100,
132141
tip=_(
133142
"The maximum number of output lines "
134-
"retained in each console at a time."
135-
"\nSpecifying -1 means no limit (not recommended)."
143+
"retained in each console at a time.\n"
144+
"Warning; Buffer sizes greater than 10000 lines can slow "
145+
"down Spyder."
136146
),
137147
)
138148
sympy_box = newcb(
@@ -146,7 +156,7 @@ def setup_page(self):
146156
)
147157

148158
output_layout = QVBoxLayout()
149-
output_layout.addWidget(buffer_spin)
159+
output_layout.addWidget(self.buffer_spin)
150160
output_layout.addWidget(sympy_box)
151161
output_group.setLayout(output_layout)
152162

@@ -182,7 +192,7 @@ def setup_page(self):
182192
(inline, 'inline'),
183193
(automatic, 'auto'),
184194
("Qt", 'qt'),
185-
("Tk", 'tk')
195+
("Tk", 'tk'),
186196
]
187197

188198
if sys.platform == 'darwin':
@@ -234,21 +244,31 @@ def setup_page(self):
234244
tip=_("Only used when the format is PNG. Default is 144."),
235245
)
236246
width_spin = self.create_spinbox(
237-
_("Width:")+" ", " "+_("inches"),
238-
'pylab/inline/width', min_=2, max_=20, step=1,
239-
tip=_("Default is 6"))
247+
_("Width:") + " ",
248+
" " + _("inches"),
249+
'pylab/inline/width',
250+
min_=2,
251+
max_=20,
252+
step=1,
253+
tip=_("Default is 6"),
254+
)
240255
height_spin = self.create_spinbox(
241-
_("Height:")+" ", " "+_("inches"),
242-
'pylab/inline/height', min_=1, max_=20, step=1,
243-
tip=_("Default is 4"))
256+
_("Height:") + " ",
257+
" " + _("inches"),
258+
'pylab/inline/height',
259+
min_=1,
260+
max_=20,
261+
step=1,
262+
tip=_("Default is 4"),
263+
)
244264
fontsize_spin = self.create_spinbox(
245265
_("Font size:") + " ",
246266
" " + _("points"),
247267
'pylab/inline/fontsize',
248268
min_=5,
249269
max_=48,
250270
step=1.0,
251-
tip=_("Default is 10")
271+
tip=_("Default is 10"),
252272
)
253273
bottom_spin = self.create_spinbox(
254274
_("Bottom edge:") + " ",
@@ -452,3 +472,19 @@ def setup_page(self):
452472
_("Advanced"),
453473
[autocall_group, autoreload_group, prompts_group, windows_group]
454474
)
475+
476+
def warn_if_large_buffer(self):
477+
"""Warn the user if the Console buffer size is very large."""
478+
if "buffer_size" not in self.changed_options:
479+
return
480+
481+
msg = None
482+
buffer_size = self.buffer_spin.spinbox.value()
483+
484+
# >10k line buffers can make Spyder slow, see spyder-ide/spyder#19091
485+
if buffer_size > 10_000:
486+
msg = _("Buffer sizes over 10000 lines can slow down Spyder")
487+
elif buffer_size == -1:
488+
msg = _("Unlimited buffer size can slow down Spyder severely")
489+
if msg:
490+
QMessageBox.warning(self, _("Warning"), msg, QMessageBox.Ok)

0 commit comments

Comments
 (0)