Key 3: Use easy drop-in faster libraries.
There are libraries out there that can help a lot in optimizing code, rather than writing some optimized routines yourself. For example, if we have a list that needs to be fast at FIFO, we may use the
blist package. We can use C versions of libraries, such as
cStringIO (faster StringIO),
ujson (faster JSON handling),
numpy (math, and vectors), and
lxml (XML handling). Most of the libraries that are listed here are just a Python wrapper over C libraries. You only need to search once for your problem domain. Other than this, we can make a C, or C++ library interface with Python very easily, which is also our next topic.