I am a godot user and a Python user. In pygame, in a simple game like pong, I had an average of 55-60 FPS in fullscreen. In addition, when ported to Kivy, I had an average FPS of 60-70FPS. But when I coded this in Godot, and got an average FPS of 180-200 in the viewport, while profiling! My program was extremely similar in both, and I wasn't static typing at all in Godot. Why is pygame so slow and is there anyway I can make it faster?
Asked
Active
Viewed 1,276 times
5
-
My guess would be that it's the engine internals that are much more efficient. – SnowGroomer Jul 21 '20 at 21:32
-
Pygame uses SDL for the graphics, maybe that is less efficient that the inbuilt 2D graphics engine of Godot or maybe Python has more overhead than Godot Script. It also might be that your program was an outlier and other attempts would show different results. Just because one try showed that pygame was slower in this example doesn't mean it always is. – NoDataDumpNoContribution Jul 21 '20 at 21:37
-
i havnt used Godot, but it looks like Godot uses faster languages like c# and c++, python is really slow compared to other languages – The Big Kahuna Jul 21 '20 at 21:46
-
Godot's main language is GDScript - a dynamically typed language with similar syntax to python. – Nv7 Jul 21 '20 at 22:21
-
@Trilarion I have tried other things and Godot is always around 80FPS faster, I just don't have any statistics on those tests. – Nv7 Jul 21 '20 at 22:22
-
Maybe it would be good to include a short description of the other things that have been tried in the question. – NoDataDumpNoContribution Jul 22 '20 at 06:41
1 Answers
5
Godot is using OpenGL ES for drawing to the window. PyGame is based on SDL, which does not use hardware graphics primitives at all. You could also port your game to Kivy, which supports OpenGL ES too.
In terms of pushing pixels to the screen, graphics being drawn with a CPU Vs running on GPU is not a contest the CPU can ever win. That said, for a whole lot of game styles, PyGame is fast enough. There is absolutely no point updating the screen faster than the monitor is refreshing.
I would expect a basic Pong in PyGame to always run at full-FPS. On a huge high-DPI display, maybe even erasing the background is enough of a pixel-load to drop the FPS.

Kingsley
- 14,398
- 5
- 31
- 53
-
I actually did make this game in Kivy - you can see it on my Github account, But it still got around 60-70FPS. Since Kivy uses PSdl2 by default, I thought that it was also using SDL and was therefore similar. I also for some reason wrote 30, I meant 55. I have updated it. – Nv7 Jul 21 '20 at 22:36
-
1It seems that [SDL might also use OpenG](https://www.libsdl.org/release/SDL-1.2.15/docs/html/guidevideoopengl.html). Maybe the pygame developers just didn't select it. I wonder if the [SDL2 based versions of pygame](https://github.com/renpy/pygame_sdl2) are faster. – NoDataDumpNoContribution Jul 22 '20 at 06:39