[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame games run slowly :(



On Jul 29, 2009, at 7:54 PM, Ian Mallett wrote:

Richie is right.  Python is not as fast as most other programming languages, so good processors are a definite bonus.  1GHz shouldn't be too much of a problem, but you could do well to upgrade it.  Likewise to the RAM--which is probably the most cost-effective way to get better results.  Your graphics card also isn't so impressive.  Personally, I recommend getting a new computer, although if cost is very much an object, upgrade the RAM.

Perhaps it's just my age and scaringly easily arising moments of nostalgia, but for me 1Ghz really is an amazingly huge amount of cycles (come on, a billion a second!) and 512mb is not little .. ps3 has 512 ram I've heard, as games often don't need much. Ram usage of a specific game you can easily see with the appropriate os tool (task manager on win, top or something on linux or macosx etc).

Yes, Python easily uses like 20x times the cpu compared to native code, but exactly because even old compus today are in the gigaherz range, it is rarely a problem - I'm often amazed how much py can do for every frame in a 60fps game.

It is very easy to make bottlenecks, very inefficient code, that you don't notice when use a powerful computer, but that show in slower ones. Sometimes it's a single a bit stupid line. That might be the case in some of the games the original poster tried, in which case it might be a good effort to profile them and optimize. Or try running with Psyco (which compiles unmodified py code to native code on the fly, with varying results (typically 2-20x speedup).

One reason why I care is that there is even an increase of weaker CPUs that can be fun for gaming: mobile devices like Maemo, Android things, iPhone .. and one laptop per child (OLPC) where pygame is already used etc. And mini-pcs typically also have a relatively weak processor (afaik 1ghz) and gfx card (some intel integrated). I think that trend is great, 'cause those machines are much cheapter to build and use *much* less electricity compared to quadcores with dualcore gpus that need their own cooling fans etc -- with current tech the world wouldn't be able to handle 6+ billion such workstations.

So if the original poster mentions the names of the games that are unexpectedly slow, perhaps the authors are curious enough to profile them for fun, or if they are open source someone else can give it a shot .. even just say 'import psyco; psyco.full()' as a test. No promises from my part though, as should work on our own pygame-in-progress instead (which occasionally run on a 400(?)Mhz maemo pad too :)

Sure if those games use opengl and need a million polygons etc. only a new gfx card could help, it all depends totally on the specifics of the game.

~Toni