I'm currently developing an heavy simulation game and has already some experience with script languages in such an area. On some of my applications there were a very strong deceleration when I used Lua or plugin based dlls. Python Interfaces are not really different.
Example:
My fractal viewer was based at first on internal codes but this was bad and not really scalable. After that I used a very simple dll interface. The performance breaks down (nearly 30%!) . I also started a lua interface. The performance breaks down once more (nearly 50%!).
So on my opinion. Don't use scripting languages in big loops (10000 iterations and up) but you can use it for simple things.
This was my experience with scripting languages. I used lua the most of the time. But lua is a little bit faster than Python, so there shouldn't be much difference.
Regards
Ömercan
Is python fast enough for a simulation heavy game similar to Dwarf Fortress?
Python can be used for games and simulations but the need for using optimization algorithms, DLL bindings (ctypes) or Cython (http://www.cython.org/) may become mandetory. Python however is a very efficient programming language.
While it seems not as popular as Pygame, I can highly recommend Pyglet for rendering your game (2D or 3D).
While it seems not as popular as Pygame, I can highly recommend Pyglet for rendering your game (2D or 3D).
Python gets a bad rep for multi-threading due to the Global Interpreter Lock. There is however no reason why you can't use multiple processes (instead of threads), and communicate over pipes/shared memory/sockets (a la Chrome's process separation model). Especially when combined with tasklets/greenlets, this can be a very efficient model.
A word on PyPy:
CPython is obviously slow, and that is somewhat intrinsic to the fact that it is a straight-forward bytecode interpreter. Others have mentioned IronPython, native code modules, or hybrids thereof (cython, shedskin, etc.), to obtain better performance, but PyPy takes the cake for simplicity, being pretty much a drop-in replacement for CPython.
Is PyPy as fast as hand-coded C modules? Not yet, but it's getting closer. It is already significantly faster than CPython for most workloads, and even measures up to cython in some places. Plus there are the cases where a tracing JIT is just plain better at optimising than a static compiler...
A word on PyPy:
CPython is obviously slow, and that is somewhat intrinsic to the fact that it is a straight-forward bytecode interpreter. Others have mentioned IronPython, native code modules, or hybrids thereof (cython, shedskin, etc.), to obtain better performance, but PyPy takes the cake for simplicity, being pretty much a drop-in replacement for CPython.
Is PyPy as fast as hand-coded C modules? Not yet, but it's getting closer. It is already significantly faster than CPython for most workloads, and even measures up to cython in some places. Plus there are the cases where a tracing JIT is just plain better at optimising than a static compiler...
Any thoughts on SDL vs SFML for c++?
I can't comment on the rest of the thread, and I'm not advocating C++ over Python, but if you do go the C++ route, I am advocating SFML over SDL (if you use C++).
[size=2]Reason: SDL has somewhat lagged in development as of the past few years though it's still chugging along, SFML has a more C++ friendly interface, multi-window support, full hardware acceleration by default (SDL's is software by default with hardware optional). They both are well documented.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement