Skip to content
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

Closed
BertrandBordage opened this issue Apr 6, 2013 · 3 comments
Closed

Cython? #33

BertrandBordage opened this issue Apr 6, 2013 · 3 comments

Comments

@BertrandBordage
Copy link
Collaborator

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.

@ghost
Copy link

ghost commented Apr 6, 2013

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.

@BertrandBordage
Copy link
Collaborator Author

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.

@BertrandBordage
Copy link
Collaborator Author

See #36 and #39 for the first successful implementation of Cython optimized modules for this game. There is a detailled description of the performance boost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant