Is there a speed advantage for this?
It is impossible to say without knowing exactly what you are doing, but the general answer is "very likely."
Is there a better (python) solution?
Again, this cannot be said. Better than that?
If you work with numeric arrays, then the first step should probably be to use NumPy .
After you have done this, there are several ways to speed up the process, in addition to coding extensions, in the original C:
- Cython : write extensions in a language like Python;
- numexpr : A mechanism for quickly evaluating array expressions.
Finally, if you find yourself writing C or C ++ extensions, consider using SWIG or Boost.Python .
source share