[NumPy-Tickets] [NumPy] #1603: in1d speed up

NumPy Trac numpy-tickets@scipy....
Thu Sep 2 16:53:42 CDT 2010


#1603: in1d speed up
--------------------+-------------------------------------------------------
 Reporter:  nhmc    |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:  2.0.0   
Component:  Other   |     Version:          
 Keywords:          |  
--------------------+-------------------------------------------------------
 Robert Kern  mentioned that in1d(ar1, ar2) can be slow for the case when
 len(ar2) is very small:

 http://article.gmane.org/gmane.comp.python.numeric.general/40077

 I've attached a script that compares timings for the existing version of
 in1d and the kern_in function described in the thread above; I use this to
 work out which algorithm is fastest for given lengths of ar1 and ar2 (see
 also the attached plot).

 Also attached is a patch that changes in1d to use the kern_in algorithm
 when it results in a speed up. I think the speedup, which can be > 10x for
 very large ar1 and very small ar2, is worth the minor increase in code
 complexity.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1603>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list