|
|
|
|
|
by nmalaguti
3213 days ago
|
|
At what point should I start thinking about rewriting computationally expensive parts of my Python application in C++ and making bindings? Does anyone have experience taking one expensive method and replacing it with C/C++? Were the trade offs worth it? |
|
Then, you try pypy. It may very well run your code 10 times faster with no work on your part.
If you can't or the result is not as good as expected, you can start using EXISTING compiled extensions. numpy, uvloop, ujson, etc.
After that, and only now, should you think about a rewrite. Numba for number related code, cython for classic hot paths or nuikta for the entire app: they can turn Python code into compiled code, and will prevent a rewrite in a low level tech.
If all of that failed, congratulation, you are part of the 0.00001%.
So rewriting bottlenecks in a compiled language is a good option. C or C++ will do. But remember you can do it in Rust too!