]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43283: Add IDLE doc paragraph about print speed (GH-24615)
authorTerry Jan Reedy <tjreedy@udel.edu>
Wed, 24 Feb 2021 00:39:51 +0000 (19:39 -0500)
committerGitHub <noreply@github.com>
Wed, 24 Feb 2021 00:39:51 +0000 (19:39 -0500)
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.

Doc/library/idle.rst
Lib/idlelib/NEWS.txt
Lib/idlelib/help.html
Misc/NEWS.d/next/IDLE/2021-02-21-16-30-10.bpo-43283.DLBwYn.rst [new file with mode: 0644]

index fc45e3161bc6d5969065953941b8422a05cafbf1..2b9bd4b5daaa77f5d642a545bc1f8e3a070d3aaf 100644 (file)
@@ -726,6 +726,15 @@ with objects that get input from and send output to the Shell window.
 The original values stored in ``sys.__stdin__``, ``sys.__stdout__``, and
 ``sys.__stderr__`` are not touched, but may be ``None``.
 
+Sending print output from one process to a text widget in another is
+slower than printing to a system terminal in the same process.
+This has the most effect when printing multiple arguments, as the string
+for each argument, each separator, the newline are sent separately.
+For development, this is usually not a problem, but if one wants to
+print faster in IDLE, format and join together everything one wants
+displayed together and then print a single string.  Both format strings
+and :meth:`str.join` can help combine fields and lines.
+
 IDLE's standard stream replacements are not inherited by subprocesses
 created in the execution process, whether directly by user code or by
 modules such as multiprocessing.  If such subprocess use ``input`` from
index 840fc622ca95e89c63f3f6757ee907a1a335aeb1..30d5b2f15f91eee6b303e2ef267eb7ccc79853ae 100644 (file)
@@ -3,6 +3,10 @@ Released on 2021-10-04?
 ======================================
 
 
+bpo-43283: Document why printing to IDLE's Shell is often slower than
+printing to a system terminal and that it can be made faster by
+pre-formatting a single string before printing.
+
 bpo-23544: Disable Debug=>Stack Viewer when user code is running or
 Debugger is active, to prevent hang or crash.  Patch by Zackery Spytz.
 
index 1eefa506e2c8d9ebb069cea06c3ca6c87885a44a..924042d25b7bab66a4b2eb965b73fd9d3b26e00c 100644 (file)
@@ -679,6 +679,14 @@ process, it replaces <code class="docutils literal notranslate"><span class="pre
 with objects that get input from and send output to the Shell window.
 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
 <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>
+<p>Sending print output from one process to a text widget in another is
+slower than printing to a system terminal in the same process.
+This has the most effect when printing multiple arguments, as the string
+for each argument, each separator, the newline are sent separately.
+For development, this is usually not a problem, but if one wants to
+print faster in IDLE, format and join together everything one wants
+displayed together and then print a single string.  Both format strings
+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>
 <p>IDLE’s standard stream replacements are not inherited by subprocesses
 created in the execution process, whether directly by user code or by
 modules such as multiprocessing.  If such subprocess use <code class="docutils literal notranslate"><span class="pre">input</span></code> from
@@ -982,7 +990,7 @@ also used for testing.</p>
 <br />
     <br />
 
-    Last updated on Feb 21, 2021.
+    Last updated on Feb 23, 2021.
     <a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
     <br />
 
diff --git a/Misc/NEWS.d/next/IDLE/2021-02-21-16-30-10.bpo-43283.DLBwYn.rst b/Misc/NEWS.d/next/IDLE/2021-02-21-16-30-10.bpo-43283.DLBwYn.rst
new file mode 100644 (file)
index 0000000..7a627af
--- /dev/null
@@ -0,0 +1,3 @@
+Document why printing to IDLE's Shell is often slower than printing to a
+system terminal and that it can be made faster by pre-formatting a single
+string before printing.