Don't always flip()

Something bugged me today. Although our game runs at a fast 60fps, it still was using about 60% of CPU on my weak eeepc. For a game mainly only active on events this is pretty bad. To solve this issue I decided to get rid of the display.flip() and use pygames.update() instead only updating parts of the screen that are more commonly used. By doing this our CPU usage was reduced to 2/3rds. More optimization to come. 

tl;dr
In case you are not writing a scrolling game: pygame.display.update() might save your framerates.

(log in to comment)

Comments

More performance hacks: since we have an event based game, we don't need to redraw the sceen if there are no events. This brings cpy load down to 9% on idle and 20% if there are events. I'm moar happy now. 
Haha yeah after your first optimization, I was like, why is he redrawing the screen every frame in the first place :)
yeah, lazyness. When I realized what we were doing and it didn't make any sense I had the same question.
 
Also, profiling is a good idea before starting any optimizations, since you'll know where the actual hot spots are. I'm loving runsnake, the squaremap is a really nice way to show where time is being spent in your programe: http://www.vrplumber.com/programming/runsnakerun/