Let's say I am manipulating a very large array of ints in numpy ( ). I want to filter it with a sublist of its values sublist. As the array is really large it looks like I need to be smart to do it in teh quickest way.
For instance:
my_array = N.random.randint(size=1e10)
sublist = [4,7,9]
#core where I extract the values of my_array equal to 4, 7 or 9
I've thought about:
cut = N.zeros((len(my_array)),dtype=bool)
for val in sublist:
cut = cut | (my_array == val)
my_array = my_array[cut]
but it would have to parse the array len(sublist) amount of time.
Still manually:
cut = N.array([value in sublist for value in my_array])
my_array = my_array[cut]
but is there a more numpytonic way of doing so?
my_arraysorted?