<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1738" rel="nofollow">http://projects.scipy.org/numpy/ticket/1738</a> on 2011-02-09 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/nbecker/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nbecker">@nbecker</a>, assigned to unknown.</em></p>
<p dir="auto">find_first would be a performance enhancement.  The current alternative would be something like:</p>
<p dir="auto">argmax (some boolean function...)</p>
<p dir="auto">which requires a lot of extra work if all you want is the index of the first occurance.</p>
<p dir="auto">This is frequently wanted for 1-d arrays, where it's meaning is unambiguous.  I think semantics for n-d (n &gt; 1) arrays is up for discussion.</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1673" rel="nofollow">http://projects.scipy.org/numpy/ticket/1673</a> on 2010-11-13 by trac user tom3118, assigned to unknown.</em></p>
<p dir="auto">The "numpy for matlab users" suggests using<br>
<code class="notranslate">nonzero(A)[0][0]</code><br>
to find the index of the first nonzero element of array A.</p>
<p dir="auto">The problem with this is that A might be a million elements long and the first element might be zero.</p>
<p dir="auto">This is an extremely common operation.  An efficient, built-in method for this would be very useful.  It also would easy people's transition from Matlab in which <code class="notranslate">find</code> is so common.</p>