Optimization

  • Avoid importing all using import *
  • Avoid re-writing functions which already exist in python. built-in functions are much faster.
  • Use specialized tools such as Numpy and Pandas, they are both optimized and compiled for fast computation.
  • Make sure that you use all resources available. such as GPU processing in pipelines.
  • Make sure that the data you wish to process is cleaned and makes sense.
  • Use generator functions(using yield) to control overhead of memory allocation.

Loops

  • Avoid Loops if alternative exists.
  • Use zip() to iterate over multiple lists

Debugging

  • Specify the exception in the Try-Except structure.

Working with Files

  • Always open files using with.