From bdf0fece5bbc2fc9fffbf0f314c7022e24e747df Mon Sep 17 00:00:00 2001
From: "Miss Islington (bot)"
<31488909+miss-islington@users.noreply.github.com>
Date: Tue, 23 Feb 2021 17:47:06 -0800
Subject: 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 2827e8a177c2a6584fada594bca6829c53a2872f)
Co-authored-by: Terry Jan Reedy
---
Doc/library/idle.rst | 9 +++++++++
Lib/idlelib/NEWS.txt | 4 ++++
Lib/idlelib/help.html | 10 +++++++++-
Misc/NEWS.d/next/IDLE/2021-02-21-16-30-10.bpo-43283.DLBwYn.rst | 3 +++
4 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 Misc/NEWS.d/next/IDLE/2021-02-21-16-30-10.bpo-43283.DLBwYn.rst
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index fc45e31..2b9bd4b 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -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
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index cf80b9e..103bf97 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,6 +3,10 @@ Released on 2021-02-15?
======================================
+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.
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 1eefa50..924042d 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -679,6 +679,14 @@ process, it replaces 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 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
@@ -982,7 +990,7 @@ also used for testing.
- Last updated on Feb 21, 2021.
+ Last updated on Feb 23, 2021.
Found a bug?
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
index 0000000..7a627af
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2021-02-21-16-30-10.bpo-43283.DLBwYn.rst
@@ -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.
--
cgit v0.12