[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Wow, big speedup in 1.49 for HWSURFACE|DOUBLEBUF and subsurface



From: "Syver Enstad" <syver-en@online.no>
> One thing I was wondering about, is it easy to gradually convert a
> Python Pygame program to a C++ SDL program? I just thought about how
> difficult it could be to prototype/design the game with Pygame and
> if/when one encountered performance or other issues that couldn't be
> solved in python, recoding that part in C++ using the SDL library (or
> some C++ wrapper around that), and exposing that code as a Python
> object.

The Python API is very easy and you can use SWIG (http://www.swig.org) to
generate the glue code between Python and C or C++.

I would avoid converting everything to C++ and use Python for that bit of
the program that needs to be flexible (scripting levels, for example) or
doesn't need high performance (options screens, displaying hiscores etc.).
Most of the performance hotspots in a game are in the graphics, which is
performed by the SDL and highly optimised.  If you have a lot of maths, that
would be faster in C or C++ than in Python, but you might be able to use
NumPy and Pygame SurfArrays to speed that up.

For example, Quake implements most of its game logic in a scripting language
and is still fast enough.

Cheers,
            Nat.

________________________________
Dr. Nathaniel Pryce
B13media Ltd.
Studio 3a, Aberdeen Business Centre, 22/24 Highbury Grove, London, N5 2EA
http://www.b13media.com



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org