I would like to make a list of tuples using two lists and a constant, as follows, I'd like to generate ob in the fast way possible. I need to make about a hundred thousand of these, so time matters...
On average the size A and B have a length of about 1000
constant = 3
A = [1,2,3]
B = [0.1,0.2,0.3]
ob = [(3,1,0.1),(3,2,0.2),(3,3,0.3)]
I know zip(A,B) can create a list of tuples but I need the constant at the beginning. Here is the code I am using at them moment, I was wondering if there is a faster way to do this
ob = []
for i in xrange(len(A)):
a = A[i]
b = B[i]
ob.append((constant,a,b))
print ob