a = [(1,2),(3,1),(4,4),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5)]
# Quite a lot tuples in the list, 6 digits~
# I want to split it into rows and columns.
rows = 5
cols = 5
Data structure is
rows and cols are the index for the bit list
[rows, cols, (data)]
I use loop to do this, but it takes too long for processing a big amount of tuples.
processed_data = []
index = 0
for h in range(0, rows - 1):
for w in range(0, cols - 1):
li = []
li = [h, w, a[index]]
processed_data.append(li)
index += 1
This operation takes too long, is there a way to do optimization? Thanks very much!