Much can be said about performance optimization, but truthfully, if you have read the entire book up to this point, you know most of the Python-specific techniques to write fast code. The most important factor in application performance will always be the choice of algorithms, and by extension, the data structures. Searching for an item within
list is almost always a worse idea than searching for an item in
Within any application, the right choice of algorithm is by far the most important performance characteristic, which is why I am repeating it to illustrate the results of a bad choice:
In : a = list(range(1000000)) In : b = dict.fromkeys(range(1000000)) In : %timeit 'x' in a ...