The fastest way to check all values from the list of coordinates

I have a list of coordinates a = [(1,2),(1,300),(2,3).....] These values area coordinates of 1000 x 1000 NumPy array.

Let's say I want to sum all the values under these coordinates. Is there a faster way to do it than:

sum([array[i[0],i[1]] for i in a])


Read more here: https://stackoverflow.com/questions/64404953/the-fastest-way-to-check-all-values-from-the-list-of-coordinates

Content Attribution

This content was originally published by Maciek Woźniak at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: