As mentioned, code optimization is the process where you try to discover the parts of your code that have a big impact on the performance of the entire program in order to make them run faster or use fewer resources.
The benchmarking section that appears later in this chapter will greatly help you to understand what is going on with your code behind the scenes and which parameters of your program have the greatest impact on the performance of your program. However, do not underestimate the importance of common sense. Put simply, if one of your functions is executed 10,000 times more than the rest of the functions of a program, try to optimize that function first.
The general advice for optimization is that you must optimize bug-free code only. This means that you must optimize working code only. Therefore, you should first try to write correct code even if that...