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-119127: functools.partial placeholders#119303

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

Closed
dg-pb wants to merge119 commits intopython:mainfromdg-pb:implement-119127

Conversation

dg-pb
Copy link
Contributor

@dg-pbdg-pb commentedMay 21, 2024
edited
Loading

As I already had implementation I though PR might be helpful for others to see and evaluate.

From all the different extensions offunctools.partial I think this one is the best. It is relatively simple and exposes all missing functionality. Otherpartial extensions that I have seen lack functionality and would not provide complete argument ordering capabilities and/or are too complicated in relation to what they offer.

Implementation can be summarised as follows:
a) All trailing placeholders are removed. (Makes things simpler)
b) Throws exception if not all placeholders are filled on call
c) retains optimization benefits of application on otherpartial instances.

Performance penalty compared to currentfunctools.partial is minimal for extension class. + 20-30 ns for initialisation and <4 ns when called with or without placeholders.

To put it simply, new functionality extendsfunctools.partial so that it has flexibility oflambda /def approach (in terms of argument ordering), but call overhead is 2x smaller.

The way I see it is that this could only be justified if this extension provided completeness and no new functionality is going to be needed anywhere near in the future. I have thought about it and tried various alternatives and I think there is a good chance that this is the case. Personally, I don't think I would ever need anything more frompartial class.

Current implementation functions reliably.

@nineteendo
Copy link
Contributor

Could you add some tests? Or is that pointless without approval?

@dg-pb
Copy link
ContributorAuthor

I was thinking to wait for approval first.

nineteendo reacted with thumbs up emoji

@nineteendo

This comment was marked as outdated.

@dg-pbdg-pb changed the titlegn-119127: functools.partial placeholdersgh-119127: functools.partial placeholdersMay 21, 2024
@dg-pb
Copy link
ContributorAuthor

If this was accepted, the implementation is ready for review. Python and C versions are in sync and tests implemented.

nineteendo reacted with thumbs up emoji

dg-pband others added9 commitsMay 25, 2024 00:38
PRpython#119321 added a comment about the magic number bumpbut did not actually apply the new magic number.
…ython#119492)``_fancy_replace()`` is no longer recursive. and a single call does a worst-case linear number of ratio() computations instead of quadratic. This renders toothless a universe of pathological cases. Some inputs may produce different output, but that's rare, and I didn't find a case where the final diff appeared to be of materially worse quality. To the contrary, by refusing to even consider synching on lines "far apart", there was more easy-to-digest locality in the output.
@erlend-aasland
Copy link
Contributor

Please open a new clean PR against main. Make sure the diff against main is correct before opening the PR.

nineteendo reacted with thumbs up emoji

@nineteendo
Copy link
Contributor

Thanks Erlend.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nineteendonineteendonineteendo left review comments

@AlexWaygoodAlexWaygoodAlexWaygood left review comments

@rhettingerrhettingerAwaiting requested review from rhettingerrhettinger is a code owner

Assignees

@rhettingerrhettinger

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

45 participants
@dg-pb@nineteendo@erlend-aasland@manueljacob@AlexWaygood@rhettinger@JelleZijlstra@tim-one@serhiy-storchaka@hugovk@pablogsal@ericsnowcurrently@barneygale@nedbat@Wulian233@scoder@gaogaotiantian@jaraco@xyb@Eclips4@adiaholic@savannahostrowski@rffontenelle@gvanrossum@sobolevn@jkunimune@vstinner@stroxler@encukou@iritkatriel@lysnikolaou@brandtbucher@skirpichev@matthiasgoergens@Zac-HD@zooba@filiplajszczak@wimglenn@colesbury@zware@Lincoln-developer@shenanigansd@emmatyping@SweetyAngel@DBJim

[8]ページ先頭

©2009-2025 Movatter.jp