Search code examples
pythonperformancemachine-learningdata-science

Python version and performance in ML


I couldn't find any answer on that question, but does Python version really matter when you implement different ML models (like catboost or xgboost) or NN (like pytorch). I do know that these models were written on C++ and other programming languages and my question may sound quite trivial, but does it really matter to upgrade Python version to increase performance and use less Memory


Solution

  • If you think about the question at a lower level - you basically have 2 components. The cpython interpreter executing statements, and the library running some optimised compute.

    Generally for a model the interpreter will take very little time (maybe microseconds). This will probably be affected by the python version, but should not be considered for performance tuning.

    You're better off checking different versions of the module, BLAS, Intel MKL, number of threads, onnx, torch jit, and similar things that will have much greater performance impacts.

    Using cprofile might help you figure out what can be improved.