-
-
Notifications
You must be signed in to change notification settings - Fork 222
Rewrite sprite collision functions #3209
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I heard somewhere (can't find a back reference) that the old "pull out a bound function into a local variable" trick is actually slower in the most recent versions of Python, I'd be interested to see you look into it with this case. EDIT: Found it-- https://youtu.be/z0-4EwIFeJo?si=sTOUIHgumGYGiyZl&t=1112 |
|
Thanks. I looked into it and found no noticeable performance increase nor penalty from either using Since I saw no performance increase from removing the cached methods/functions, I will leave it in just in case python 3.9 or 3.10 needs it. |
MyreMylar
left a comment
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.
OK, LGTM 👍
Nice simplification. I renamed the 'crashed' variable because it's name didn't make much sense and this was a good opportunity.
ankith26
left a comment
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, thanks for the PR 🎉
After looking around for a bit trying to think of any case where doing a kill later would change behaviour I have not come up with anything. So I think this is safe to merge
The current sprite collision functions code has some code repetition. This implementation structures it differently, which has a few effects.
dokillis true inspritecollideorgroupcollide, the sprites are killed after all colliding sprites have been determined, instead of during iteration (should be unnoticeable)group.sprites()is replaced by iteration overgroupitself, resulting in the following:dokillis False)dokillis False)ignore_selfparameter, e.g., with the new structurePerformance tested in 3.13.0, no regression (similar performance).
Renamed a few local variables for clarity.