title: fast python numpy where functionality?
body: <p>I am using numpy's where function many times inside several <code>for</code> loops, but it becomes way too slow. Are there any ways to perform this functionality faster? I read you should try to do in-line for loops, as well as make local variables for functions before the <code>for</code> loops, but nothing seems to improve speed by much (&lt; 1%). The <code>len(UNIQ_IDS)</code> ~ 800. <code>emiss_data</code> and <code>obj_data</code> are numpy ndarrays with shape = (2600,5200). I've used <code>import profile</code> to get a handle on where the bottlenecks are, and <code>where</code> in <code>for</code> loops is a big one.</p>
  
  <pre><code>import numpy as np
  max = np.max
  where = np.where
  MAX_EMISS = [max(emiss_data[where(obj_data == i)]) for i in UNIQ_IDS)]
  </code></pre>