GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-107369: Optimise ``textwrap.indent()`` by AA-Turner · Pull Request #131923 · python/cpython

Conversation

@AA-Turner

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

Uh oh!

There was an error while loading. Please reload this page.

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

  • Issue: Optimize textwrap.indent() #107369

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AA-Turner
Optimise textwrap.indent()
bd5784e
@AA-Turner
AA-Turner requested a review from picnixz March 31, 2025 01:09
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 31, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Mar 31, 2025
Optimize textwrap.indent() #107369
Closed
picnixz
picnixz approved these changes Mar 31, 2025
View reviewed changes

@picnixz picnixz left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 31, 2025
@AA-Turner

AA-Turner commented Mar 31, 2025

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

picnixz reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner
AA-Turner merged commit 51e0f2b into python:main Mar 31, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 31, 2025
@AA-Turner
AA-Turner deleted the tw-indent branch March 31, 2025 17:31
methane
methane reviewed Apr 15, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-03-31-02-06-57.gh-issue-107369.8M-HVz.rst
@@ -0,0 +1,2 @@
Improved performance of :func:`textwrap.dedent` by an average of ~1.3x.

@methane methane Apr 15, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

s/dedent/indent/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@methane methane methane left review comments
@picnixz picnixz picnixz approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@AA-Turner @methane @picnixz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.