Skip to content
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

Switch to using generator expressions for sprite collision detection #46

Open
wkeeling opened this issue Sep 22, 2016 · 0 comments
Open

Comments

@wkeeling
Copy link
Owner

wkeeling commented Sep 22, 2016

Rather than creating temporary lists when filtering sprites for collision detection, use generator expressions. This is more efficient as it means that fewer lists have to be created in memory.

e.g.

sprites_collided = pygame.sprite.spritecollide(self, (s for s in self._collidable_sprites if s.visible), False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant