On 5/29/07, dmitrey <openopt@ukr.net> wrote:
hi all,
I have 2 sorted arrays arr1 & arr2 (ascending order, for example
[1,2,5,8] and [3,5], but length may be thousands, so I need simpliest
way, not costly).
Howto obtain arr3 that consists of elements present in arr1 but absent
in arr2?
Of course, I can write something by myself, like
arr3 = [x for x in arr1 if not x in arr2]
but maybe already written routines are present in numpy? (that use sort)

Usually arr2 is much more small than arr1, typical former size is 10-20
and typical latter size can be 1000-10000


count = arr2.searchsorted(arr1, side='right') - arr2.searchsorted(arr1, side='left')
arr3 = arr1[count == 0]

Chuck