Code in Python is not typically built for speed but it is improved with compilers such as Nuitka, PyPy, and Cython. It often helps to know how long certain sections of code require to run so that those sections can be optimized, parallelized, or compiled.
Sometimes a certain section of code is a majority of the run-time so the code may be ported to a compiled language such as C++ or Fortran that is then called from Python, especially if improving a particular section can greatly reduce the total time. That one section may be converted to a langauge that is built for speed and then called by Python. The following tutorial shows to how to implement a simple timer on sections of code.
For more complex projects, a profiler such as profile or cProfile maybe a better solution to avoid the extra timer code and for a more comprehensive analysis.