Find all occurences of a specified match of two numbers in numpy array
<p>what i need to achieve is to get array of all indexes, where in my data array filled with zeros and ones is step from zero to one. I need very quick solution, because i have to work with milions of arrays of hundrets milions length. It will be running in computing centre. For instance..</p>

<pre><code>data_array = np.array([1,1,0,1,1,1,0,0,0,1,1,1,0,1,1,0])
result = [3,9,13]
</code></pre>

<p>Well thanks a lot to all of you. Solution with nonzero is probably better for me, because I need to know steps from 0->1 and also 1->0 and finally calculate differences. So this is my solution. Any other advice appreciated .)</p>

<pre><code>i_in  = np.nonzero(  (data_array[1:] - data_array[:-1]) ==  1   )[0] +1
i_out = np.nonzero(  (data_array[1:] - data_array[:-1]) == -1   )[0] +1

i_return_in_time = (i_in - i_out[:i_in.size] ) 
</code></pre>

python arrays performance numpy