Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

picnixz
Copy link
Member

@picnixzpicnixz commentedJul 29, 2023
edited by bedevere-bot
Loading

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
Copy link

ghost commentedJul 29, 2023
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Pythonrequire a NEWS entry.

Please add it using theblurb_it web app or theblurb command-line tool.

@methane
Copy link
Member

Our goal is not only maximize performance. Andtextwrap.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 forpredicate 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. Soappend = L.append before loop has only little venefit.

@picnixzpicnixz deleted the gh-107424-optimize-textwrap-indent branchJuly 30, 2023 07:13
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@picnixz@bedevere-bot@methane

[8]ページ先頭

©2009-2025 Movatter.jp