code: def memory_usage():
      
      try:
          import psutil
          import os
      except ImportError:
          return _memory_usage_ps()
  
      process = psutil.Process(os.getpid())
      mem = process.memory_info()[0] / float(2 ** 20)
      return mem
docs: return memory usage of python process in MB
  
      from
      http://fa.bianp.net/blog/2013/different-ways-to-get-memory-consumption-or-lessons-learned-from-memory_profiler/
      psutil is quicker
  
      >>> isinstance(memory_usage(),float)
      True