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

Re: [pygame] pygame performance



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.

psyco is an easy speed-up for some things with no changes to the code,
but it only works on 32-bit x86 platforms with 4 byte stack alignment
(basically everything but Mac OS X Intel).

If you still need more optimization you start translating small pieces
to a lower level language, but only the pieces that are proven to be a
bottleneck by profiling. This is often not necessary.

-bob

On 10/18/06, Lionel Barret de Nazaris <lionel.bdn@xxxxxxx> wrote:
In other words, you could consider python as the "prototype code".
it is not fast but it is easy to code and therefore to something working
quickly.
Once everything, and i mean everything, is in place (i.e you have
overcome all obstacles), you replace part of the "prototype code" that
need it by translating it to c++/Delphi/D (or using psyco)...
The key words are "overcoming obstacles".
Much much easier than the traditionnal way  "bottom up from c++ to script".

L.

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).
>
> -bob
>
>
> On 10/18/06, Marcelo de Moraes Serpa <celoserpa@xxxxxxxxx> wrote:
>> I'm not into 3D yet either. But I really don't like slow rendering
>> speeds on
>> 2D games. Blitz has an incredible fast 2D rendering speed but the
>> language
>> is basic and I don't like basic!
>>
>>
>>  On 10/18/06, Mark Mruss <selsine@xxxxxxxxx> wrote:
>> > Yeah the performance of pyGame has always been a question for me,
>> > especially since I'm thinking of writing the entire game in straight
>> > python/pyGame.  Not a 3d game of course but a simple 2d game, a side
>> > scroller or puzzle game, and PyGame seems like a nice way to keep
>> > things simple.
>> >
>> > So for me I'd love to hear about what kind of performance people have
>> > been able to achieve using straight PyGame, and whether or not it
>> > makes sense to try this...
>> >
>> > mark.
>> >
>> >
>> > On 10/18/06, Marcelo de Moraes Serpa < celoserpa@xxxxxxxxx> wrote:
>> > > >So except if you want to code the next Unreal, you should have
>> > > >everything you need.
>> > >
>> > > Actually I want to code Quake 5 :D lol..
>> > >
>> > > That was just for the sake of curiosity. Thanks for the the info, it
>> helps
>> > > knowing how python works.
>> > >
>> > > Marcelo.
>> > >
>> > >
>> > >
>> > >
>> > > On 10/18/06, Lionel Barret de Nazaris < lionel.bdn@xxxxxxx> wrote:
>> > > > Marcelo de Moraes Serpa wrote:
>> > > > > Hello list!
>> > > > >
>> > > > > I used to use Blitz Basic to develop games some time ago. Now, I
>> want
>> > > > > to play with the wonderful world of game development again. I've
>> found
>> > > > > python to be a extremelly elegant, powerful and easy to use
>> language,
>> > > > > so, pygame seems to fit perfectly for what I'd like to do.
>> However,
>> > > > > I've seen some games made with pygame and found that their
>> overall
>> > > > > rendering speed is quite slow if you compare to other languages
>> (Blitz
>> > > > > Basic is actually quite fast). Maybe it was an isolated issue
>> but
>> I'd
>> > > > > really like to know from more experinced developers on the
>> performance
>> > > > > of python/pygame.
>> > > > >
>> > > > > Thanks in advance,
>> > > > >
>> > > > > Marcelo.
>> > > > Mmm...i don't know much about blitz basic but AFAIK it is a static
>> typed
>> > > > / compiled language.
>> > > > Python is interpreted which make it slower (it cannot guess the
>> > > > execution path as almost anything can be changed at runtime).
>> > > > For most app, the relative slowness in not important and largely
>> > > > compensated by the productivity boost.
>> > > >
>> > > > Games are in the gray area. the many loops (rendering,
>> collision, etc)
>> > > > imply many function calls which is slow in python.
>> > > > Complex 3D (like seen in commercial AAA games) is quite out of the
>> > > > question for now *but* simple games are very easy to do. With
>> the help
>> > > > of openGL it quite easy to get over 100 fps.
>> > > >
>> > > > So except if you want to code the next Unreal, you should have
>> > > > everything you need.
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > >
>> > >
>> >
>>
>>
>
>