📝 Worksheet← Lesson← Course
BitWithBite
Pygame Mastery · Quick Reference

Optimization & Publishing Cheat Sheet

Pygame Mastery
In one line: Convert images for fast blitting, profile before optimizing, then package with PyInstaller and ship to itch.io.

Key Ideas

1convert()/convert_alpha(). Matches pixel format to the display — the single biggest, cheapest blitting speedup.
2Sprite Group Efficiency. Use pygame.sprite.Group.draw()/.update() rather than manual loops for cleaner, often faster code.
3Profiling First. Measure with cProfile before optimizing — don't guess where the slowdown actually is.
4PyInstaller. Packages your .py script + dependencies into a standalone .exe/app users can run without installing Python.
5Publishing. itch.io is the standard free hosting platform for indie/hobby Pygame projects — upload the packaged build + a description page.

PyInstaller Command

pyinstaller --onefile --windowed game.py
--onefile
bundles everything into a single .exe
--windowed
suppresses the console window (GUI apps)
22 FPSBefore60 FPSAfter
convert_alpha() plus sprite-group batching turned a 22 FPS crawl into a smooth 60 FPS — profile first, then optimize the real bottleneck.