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

Move pg_tuple_from_values_int into header, rename & add triple variant#3530

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

Merged

Conversation

@MyreMylar
Copy link
Contributor

Related to the suggestion in#3424 by@Starbuck5 to reduce code duplication by having copies of this function each time it gets used.

As far as I can tell there is no obvious reasonnot to have inline functions in header files with Pygame 3. The existing #define style 'functions' ininclude/_pygame.h appear to have been designed that way for something calledCObjects in Python 2 (according to the header comment in the file) which were then removed in Python 3.

Happy to hear wisdom otherwise, or create a new file instead if we think that is better, but the existing #define macro functions in this header are the most similar to the purpose of this function. Also, this header is already included everywhere.

Testing work: does this change the performance in any way versus having it directly inrect.c. It shouldn't but hey, compilers are weird.

@MyreMylar
Copy link
ContributorAuthor

MyreMylar commentedNov 1, 2022
edited
Loading

Relatedly, I found this accepted PEP on removing macros from python in favour of inline functions:

https://peps.python.org/pep-0670/

@Starbuck5
Copy link
Contributor

It would be great to have a comment with the function explaining its function and purpose.

iirc:
Converts two integers to a python tuple faster than the general purpose PyBuild_Value way.

@MyreMylar
Copy link
ContributorAuthor

It would be great to have a comment with the function explaining its function and purpose.

iirc: Converts two integers to a python tuple faster than the general purpose PyBuild_Value way.

Yeah, I think we will also want to rename this to "couple" and create a second version "triple" for three values into a tuple.

I can rejig this PR - or we could keep this one as a simple move and do the rename, rejig an comments in a new PR? Dunno what would be preferred for ease of review.

@Starbuck5
Copy link
Contributor

I’d prefer comment now and rejig later if at all.

That puts us in a good spot for readability now and potentially later.

- Also add explanatory comment for why this was made
@MyreMylar
Copy link
ContributorAuthor

Decided to just do the rename now and triple variant now as well.

The triple will likely be used for thecolor.rgb setter in that PR

@itzpr3d4t0r
Copy link
Contributor

In our pygame_geometry project we settled on a different name for the function that i think is a bit better than this one, though i'll just throw it out there, no forcing:
pg_TupleFromIntPair

@MyreMylar
Copy link
ContributorAuthor

In our pygame_geometry project we settled on a different name for the function that i think is a bit better than this one, though i'll just throw it out there, no forcing:pg_TupleFromIntPair

Now I'm just annoyed about the rapid switching between CamelCase and underscores in function names all over pygame...

Anyway, I'm happy to switch to whatever name or case arrangement as long as we have a logical way to distinguish between the couple/pair tuple and the triple/trio and are consistent.

Copy link
Contributor

@Starbuck5Starbuck5 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

Copy link
Contributor

@ankith26ankith26 left a comment

Choose a reason for hiding this comment

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

LGTM! 👍
Definitely nice to reduce duplication and have functions like these in common files.

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

Reviewers

3 more reviewers

@Starbuck5Starbuck5Starbuck5 approved these changes

@ankith26ankith26ankith26 approved these changes

@gresmgresmgresm approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

C codeInvolves changing C codeCode quality/robustnessCode quality and resilience to changes

Projects

None yet

Milestone

2.2.0

Development

Successfully merging this pull request may close these issues.

6 participants

@MyreMylar@Starbuck5@itzpr3d4t0r@ankith26@gresm

[8]ページ先頭

©2009-2025 Movatter.jp