gh-107369: Optimise ``textwrap.indent()`` by AA-Turner · Pull Request #131923 · python/cpython
Conversation
Follow-up to #131919, I noticed there was opportunity for improvement here too, a ~30% speed-up.
| Benchmark | textwrap | new |
|---|---|---|
| indent | 3.59 ms | 2.81 ms: 1.28x faster |
Benchmarked by indenting the contents of Objects/unicodeobject.c.
A
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see that PR! I think the optimisation is worth it, it's a small change and a reasonable speed-up for the default case (predicate=None). I'll give you co-authored-by credit!
A
| @@ -0,0 +1,2 @@ | |||
| Improved performance of :func:`textwrap.dedent` by an average of ~1.3x. | |||
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/dedent/indent/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters