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

Joachim Saul list at jsaul.de
Thu Jan 30 01:20:04 CST 2003


* John Hunter [2003-01-29 22:13]:
> 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?

X = transpose(array([x]+[y]))

It may not be the fastest possible way, but should be about a
factor of two faster; better than nothing.

Cheers,
Joachim




More information about the Numpy-discussion mailing list