- Notifications
You must be signed in to change notification settings - Fork3.8k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
MyreMylar commentedNov 1, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Relatedly, I found this accepted PEP on removing macros from python in favour of inline functions: |
It would be great to have a comment with the function explaining its function and purpose. iirc: |
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. |
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
Decided to just do the rename now and triple variant now as well. The triple will likely be used for the |
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: |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks good, thanks!
There was a problem hiding this 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.
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' in
include/_pygame.happear 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 in
rect.c. It shouldn't but hey, compilers are weird.