Skip to content

Commit 41a7ea8

Browse files
committed
Note the textwrap.dedent optimisation and behaviour change
1 parent 6aa88a2 commit 41a7ea8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Doc/library/textwrap.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ functions should be good enough; otherwise, you should use an instance of
102102
print(repr(s)) # prints ' hello\n world\n '
103103
print(repr(dedent(s))) # prints 'hello\n world\n'
104104

105+
.. versionchanged:: next
106+
The :func:`!dedent` function now correctly normalizes blank lines containing
107+
only whitespace characters. Previously, the implementation only normalised
108+
blank lines containing tabs and spaces.
105109

106110
.. function:: indent(text, prefix, predicate=None)
107111

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,14 @@ io
10721072
:gh:`120754` and :gh:`90102`.)
10731073

10741074

1075+
textwrap
1076+
--------
1077+
1078+
* Optimise the :func:`~textwrap.dedent` function, improving performance by
1079+
an average of 2.4x, with larger improvements for bigger inputs,
1080+
and fix a bug with incomplete normalization of blank lines with whitespace
1081+
characters other than space and tab.
1082+
10751083
uuid
10761084
----
10771085

0 commit comments

Comments
 (0)