FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-107369: Optimise ``textwrap.indent()`` by AA-Turner · Pull Request #131923 · python/cpython · GitHub

/ cpython Public

gh-107369: Optimise textwrap.indent() - #131923

Merged
AA-Turner merged 1 commit into
python:mainfrom
AA-Turner:tw-indent
Mar 31, 2025
Merged

gh-107369: Optimise textwrap.indent()#131923
AA-Turner merged 1 commit into
python:mainfrom
AA-Turner:tw-indent

Conversation

AA-Turner commented Mar 31, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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

picnixz left a comment
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is funny because this was my very first attempt at CPython: https://github.com/python/cpython/pull/107426/files :') It was rejected at that time (#107426 (comment)) though

Copy link
Copy Markdown
Member Author

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

AA-Turner merged commit 51e0f2b into python:main Mar 31, 2025
AA-Turner deleted the tw-indent branch March 31, 2025 17:31
@@ -0,0 +1,2 @@
Improved performance of :func:`textwrap.dedent` by an average of ~1.3x.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL