Right now I have an image processing algorithm that is roughly 100 lines or so in Python. It takes about 500ms using numpy
, PIL
and scipy
. I am looking to get it faster, and as the actual algorithm seems pretty optimized thus far, I'm wondering if using a different approach such as Cython
would improve the times. I believe that I have several different things I could do:
- Use Cython to expose relevant parts of the C library to Python.
- Use Ctypes to just write everything in C but still have it pure Python (not leaning towards this at all)
- Create an extension module in C/C++ and them import it and call the functions. I'm not sure if I would be able to use
numpy
this way though. - Create a DLL and have Python load it. This doesn't get to use
numpy
or those modules, but would still be very efficient.
I'm just looking for speed here, not worried about difficulty of the implementation. Is there any one option that is better in this case, are they all the same, or is it even worth doing?