[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 CST 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
    do_something_with(X)

Is this the fastest way?

Thanks,
John Hunter




More information about the Numpy-discussion mailing list