8000 bpo-43283: Add IDLE doc paragraph about print speed (GH-24615) (GH-24… · python/cpython@bdf0fec · GitHub
[go: up one dir, main page]

Skip to content

Commit bdf0fec

Browse files
bpo-43283: Add IDLE doc paragraph about print speed (GH-24615) (GH-24632)
Printing to IDLE's Shell is often slower than printing to a system terminal, but it can be made faster by pre-formatting a single string before printing. (cherry picked from commit 2827e8a) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent 9dd018e commit bdf0fec

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

Doc/library/idle.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,15 @@ with objects that get input from and send output to the Shell window.
726726
The original values stored in ``sys.__stdin__``, ``sys.__stdout__``, and
727727
``sys.__stderr__`` are not touched, but may be ``None``.
728728

729+
Sending print output from one process to a text widget in another is
730+
slower than printing to a system terminal in the same process.
731+
This has the most effect when printing multiple arguments, as the string
732+
for each argument, each separator, the newline are sent separately.
733+
For development, this is usually not a problem, but if one wants to
734+
print faster in IDLE, format and join together everything one wants
735+
displayed together and then print a single string. Both format strings
736+
and :meth:`str.join` can help combine fields and lines.
737+
729738
IDLE's standard stream replacements are not inherited by subprocesses
730739
created in the execution process, whether directly by user code or by
731740
modules such as multiprocessing. If such subprocess use ``input`` from

Lib/idlelib/NEWS.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Released on 2021-02-15?
33
======================================
44

55

6+
bpo-43283: Document why printing to IDLE's Shell is often slower than
7+
printing to a system terminal and that it can be made faster by
8+
pre-formatting a single string before printing.
9+
610
bpo-23544: Disable Debug=>Stack Viewer when user code is running or
711
Debugger is active, to prevent hang or crash. Patch by Zackery Spytz.
812

Lib/idlelib/help.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,14 @@ <h3>Running user code<a class="headerlink" href="#running-user-code" title="Perm
679679
with objects that get input from and send output to the Shell window.
680680
The original values stored in <code class="docutils literal notranslate"><span class="pre">sys.__stdin__</span></code>, <code class="docutils literal notranslate"><span class="pre">sys.__stdout__</span></code>, and
681681
<code class="docutils literal notranslate"><span class="pre">sys.__stderr__</span></code> are not touched, but may be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
682+
<p>Sending print output from one process to a text widget in another is
683+
slower than printing to a system terminal in the same process.
684+
This has the most effect when printing multiple arguments, as the string
685+
for each argument, each separator, the newline are sent separately.
686+
For development, this is usually not a problem, but if one wants to
687+
print faster in IDLE, format and join together everything one wants
688+
displayed together and then print a single string. Both format strings
689+
and <a class="reference internal" href="stdtypes.html#str.join" title="str.join"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.join()</span></code></a> can help combine fields and lines.</p>
682690
<p>IDLE’s standard stream replacements are not inherited by subprocesses
683691
created in the execution process, whether directly by user code or by
684692
modules such as multiprocessing. If such subprocess use <code class="docutils literal notranslate"><span class="pre">input</span></code> from
@@ -982,7 +990,7 @@ <h3>Navigation</h3>
982990
<br />
983991
<br />
984992

985-
Last updated on Feb 21, 2021.
993+
Last updated on Feb 23, 2021.
986994
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
987995
<br />
988996

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Document why printing to IDLE's Shell is often slower than printing to a
2+
system terminal and that it can be made faster by pre-formatting a single
3+
string before printing.

0 commit comments

Comments
 (0)
0