Sign up, and you can make all message times appear in your timezone. Sign up
Sep 27, 2024
4:02:45pm
AggieWeekendCougar Political Junky
I had never really used Cython before to generate C from python and then compile
it to faster running code.

I have a fairly long-running simulation that is mostly done in Python (with some numpy and scipy under the hood). I decided to try Cython and it sped it up by about 50%. It won't speed up any of the stuff under the hood that is already in C (like much of numpy and scipy), but it will speed up any of your own loops.

It was as easy as renaming my file to .pyx, finding the standard setup.py to run Cython on it. It creates a shared library that can then just be imported and the python code inside of it being available to the interpreter.

Wish I would have known about this a long time ago.
AggieWeekendCougar
Bio page
AggieWeekendCougar
Joined
Sep 23, 2013
Last login
Dec 21, 2024
Total posts
15,806 (122 FO)