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

Re: [pygame] Python and Speed



In that specific case, no matter which programming language you use,
your code will not be very fast.  Do you think programmers write
unoptomized code in c, and get speedy execution every time?  Have you
not ever used a program or played a game which ran slower than it
should, which was actually programmed in a fast language?  Optiomizing
code and improving algorithms have been around far longer than python,
and are an important part of programming in general.  As has been
mentioned before, there have been many attempts to optimize core
python, which have resulted in some improvements.  Python2.5 is
considerably faster than python1.0.  However, due to the nature of the
language it can only be optimized so much.  The best bet really, is to
write code in c that needs to be fast, and call that code from python,
using python as a glue language.  This can be accomplished using
implementations that already exist (pyode, numpy) or writing a new
implementation and exposing it with pyrex or other linking programs.

There is no magic bullet that will make python faster, and it's not
for lack of trying.  Even at it's most optimized that could
theoretically be done, I don't think pure python will ever be as fast
as c.  I do hope it gets close, but even if this were to be the case,
your collision detection code will still be slow as heck.  Culling
algorithms for this purpose were invented to speed up applications
written in C after all :)