[Numpy-discussion] fastest way to make two vectors into an array

John Hunter jdhunter at ace.bsd.uchicago.edu
Wed Jan 29 13:13:03 EST 2003

I have two equal length 1D arrays of 256-4096 complex or floating
point numbers which I need to put into a shape=(len(x),2) array.

I need to do this a lot, so I would like to use the most efficient
means.  Currently I am doing:

def somefunc(x,y):
    X = zeros( (len(x),2), typecode=x.typecode())
    X[:,0] = x
    X[:,1] = y

Is this the fastest way?

John Hunter

More information about the NumPy-Discussion mailing list