Using the right algorithms and data structures
Algorithmic improvements are especially effective in increasing performance because they typically allow the application to scale better with increasingly large inputs.
Algorithm running times can be classified according to their computational complexity, a characterization of the resources required to perform a task.
Such classification is expressed through the Big O notation, an upper bound on the operations required to execute the task, which usually depends on the input size. Specifically, Big O notation describes how the runtime or memory requirement of an algorithm grows in terms of the input size. For this reason, a lower Big O denotes a more efficient algorithm, which is what we aim for.
For example, incrementing each element of a list can be implemented using a for
loop, as follows:
input = list(range(10)) for i, _ in enumerate(input): ...