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

Re: [pygame] pygame performance



On Thursday 19 October 2006 04:14, Bob Ippolito wrote:
> There's always ways to optimize things later. Write the code. If it's
> not fast enough, *profile* the code to see what's not fast, and take
> steps to optimize that part of the code.
> 
> Sometimes using psyco is going to be enough, depending on which
> platforms you care about. Otherwise you could change the rendering
> strategy to use OpenGL (which is still the fastest way to do anything,
> even in 2D), or writing some of the tight loops in C or C++ (possibly
> via Pyrex).

This is very good advice and bears repeating through just quoting it again :)

I should also note that I've written quite a number of action-oriented games 
in Python now and have *never* had to resort to coding parts of them in C or 
C++.

If you find your game is slow and you can't figure out how to improve 
performance, I recommend asking for advice on this list. That almost always 
results in improvements.

For example: I went down the re-coding-in-C path once a long time ago when I 
was writing a 3D game. I coded a number of parts of the low-level rendering 
in C in response to poor performance. Then someone clued me in to OpenGL 
display lists. I ditched the C bits because they were *slower* than using 
display lists.


    Richard

ps. there's a wiki page somewhere out there that lists python game speed tips. 
I know there is. I can't find it though :(