I have a long list of (i, j, value) pairs, with multiple values for each position, the number of values varies for each position.
At the moment I am initializing an empty “3d” list with
sorted = numpy.empty((m, n, 0)).tolist()
then I loop over each entry in the array and append the value to the list at i, j.
for pixel in value_list:
sorted[pixel[0]][pixel[1]].append(pixel[2])
This is slow and hard to parallelize since I have to write to the same lists and don´t know how long they are going to be at the end.
Is there a faster solution to this? I am sure this is a common problem but maybe I just don´t now what I have to look for.
This is slow and hard to parallelize since I have to write to the same lists and don´t know how long they are going to be at the end.
Is there a faster solution to this? I am sure this is a common problem but maybe I just don´t now what I have to look for.