-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cython? #33
Comments
I think we should use Cython, but only to the most important functions. We should also keep pure Python equivalents. The game is sometimes very slow, so every performance update is needed. We can also add some command line argument to switch between Cython and Python code. |
There is a nice feature of Cython called Pure Python Mode to achieve such a compatibility. Using "magic attributes" seem painful and requires to have Cython installed, even if you don't use the compiled binaries. But the solution of having .py files of pure Python and .pxd files where C types are defined looks like a perfect solution! I start working on this. |
After doing some experiments using numpy (see #30), I managed to save some execution time.
Now I made some experiments using Cython. And some sensible functions are executed more than 10 times faster. I therefore wonder whether we should use Cython (that mixes beautifully with numpy).
If we make an advanced terrain generator like in the original game, I bet that we will quickly see the limits of Python. And unfortunately, pyglet is not thread-safe, so it may be impossible to do parallel computations.
And of course, the main problem with Cython is that we have to compile (beautiful) code.
The text was updated successfully, but these errors were encountered: