I struggle to write find the best "question" so please feel free to suggest another title.
Lets say I have a=np.array([5,3,2,4]) and b=np.array([1,2]) - I want to get a list of list (or np.arrays) with the value of a>b[i] i.e it can be written as a list comprehension
[a[i]>p for p in b] which returns
[np.array([True,True,True,True]), np.array([True,True,False,True])]. Since I have a rather large data set I hoped that there was a numpy function to do such, or is list comprehension the better way here?
ais really large (close to your memory limit), you may want to processa > b[i]separately anyway and in that case I would look no further than a simple loop, which is slow but can have a small memory footprint. Otherwise, you can use broadcasting which is fast but has a large memory footprint. List-comprehension in this case has both disadvantages: slow and large memory footprint.