4 ms·
Do you have advice for finding code snippets that would most benefit from being re-written in C and called with Cython? I know how to find slow functions in Pyt
by Alex3917 7y ago
Do you have advice for finding code snippets that would most benefit from being re-written in C and called with Cython? I know how to find slow functions in Python, but obviously not every slow function will be a good candidate for rewriting.
- fnbr 7y agoIn my experience, most pure python code will be 10 to 100x faster if it’s rewritten in C++. So I just profile it as usual using cProfile, try to make algorithmic improvements (eg caching) and then, if I need another order of magnitude, rewrite it in C++. So basically anything where the hot path is in pure Python, rather than a standard library method.