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

gh-107424: avoid using lambda functions in ``textwrap.indent()`` by picnixz · Pull Request #107426 · python/cpython · GitHub

/ cpython Public

gh-107424: avoid using lambda functions in textwrap.indent() - #107426

Closed
picnixz wants to merge 1 commit into
python:mainfrom
picnixz:gh-107424-optimize-textwrap-indent
Closed

gh-107424: avoid using lambda functions in textwrap.indent()#107426
picnixz wants to merge 1 commit into
python:mainfrom
picnixz:gh-107424-optimize-textwrap-indent

Conversation

picnixz commented Jul 29, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

As mentioned by #107374 (comment), avoiding the use of a lambda function when no predicate is specified is expected to improve the performances.

The benchmarks reported on the issue corroborate this assumption. However, I would like to know if this is only because my laptop is dying (caching .append calls do not seem to help however).

I am waiting for changes to be verified before creating a NEWS entry (should I create it in conjunction to the already created one by @methane ?)

ghost commented Jul 29, 2023
edited by ghost
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

methane commented Jul 30, 2023

Copy link
Copy Markdown
Member

Our goal is not only maximize performance. And textwrap.indent() is not performance critical for most applications as far as I know.

In #107374, I made the code slightly simpler by removing generator.
On the other hand, this change makes maintenance cost little higher. We need to review and test the case for predicate is passed.
That's why I didn't incude this change in my PR.

(caching .append calls do not seem to help however).

Yes. It is old technique. Recent Python has little method call overhead. So append = L.append before loop has only little venefit.

methane closed this Jul 30, 2023
picnixz deleted the gh-107424-optimize-textwrap-indent branch July 30, 2023 07:13
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL