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

Re: [pygame] pygame performance



On 10/18/06, Bob Ippolito <bob@xxxxxxxxxx> wrote:
Once everything is in place you first replace code that's slow with
better algorithms. If you still need better performance, then you try
other means. It usually is fast enough at this point, and you're done.
In many cases you can beat (naive) C or C++ in speed simply because
it's more natural to write good algorithms and use appropriate data
structures in Python.

Bob has it exactly right here - the algorithm and approach for what
you are doing is usually much more significant than the speed of the
language or operations (an excellent thing to be aware of when
optimizing in any language).

It is true that python is much much slower than compiled languages to
the tune of 20 to 1 or so for a lot of things (stuff like flattening
bezier curves, drawing gradients pixel by pixel, or updating thousands
of tiny particles, inner loop stuff), but I find it's so easy to put
together cleaner, more readable and more intelligent code with python
that I spend much less time needing to optimize than I do with C++
game development. Sure C++ executes faster, but people will write much
dumber and more wasteful code in it in my experience. I'm suprised how
many times I find people having written code that ends up drawing
everything twice, or reloading assets unnecessarily, or doing very
naive brute force solutions etc. on top of a well tested c++ engine.