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

implementation of theminmax function#144382

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
Marius-Juston wants to merge4 commits intopython:mainfromMarius-Juston:minmax

Conversation

@Marius-Juston
Copy link
Contributor

Theminmax function implementation

This pull request implements theminmax function, which is very similar to themin andmax functions; however, makes it much more efficient to compute both themin and themax values in a single pass. This is extremely useful for a lot of applications, for example it can be used inside thetextwrap.dedent (#131919 ) function inside Python, themin andmax functions are also very often used inside statical methods to compute the range of values.

The advantage of this system is that instead of doing 2 passes inside the dataset / iterable, it can be once.

The function would be defined as:

(min_val, max_val) = minmax([1,2,34,45,6])

This probably needs a PEP (I am just familiar enough with the process so I am putting Pull request first)

@Marius-Juston
Copy link
ContributorAuthor

Also inside themin_max function that is already defined it would probably make it more readable if:

(line 2044 of bltinmodule.c)

if (cmp<0)    gotoFail_it_item_and_val;

and

(line 2067 of bltinmodule.c)

elsePy_DECREF(maxval);

used brackets as,

(line 2044 of bltinmodule.c)

if (cmp<0) {    gotoFail_it_item_and_val;}

and

(line 2067 of bltinmodule.c)

else {Py_DECREF(maxval);}

I can add this to my pull request if we want as well.

@Marius-Juston
Copy link
ContributorAuthor

It might not necessary make complete sense for this function to be part of thebuiltin since it's functionality is so close tomin andmax and maybe it should be moved to themath portion of the library instead or something?

@picnixzpicnixz closed thisFeb 1, 2026
@picnixz
Copy link
Member

picnixz commentedFeb 1, 2026
edited
Loading

Please do not create PRs for features without a discussion. This is not the way contribution works here. The workflow is explained in the devguide which was referenced in this repo's README.

Marius-Juston and tim-one reacted with thumbs up emoji

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

Reviewers

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@Marius-Juston@picnixz

[8]ページ先頭

©2009-2026 Movatter.jp