Numeric/Numarray equivalent to zip ?
Peter Otten
__peter__ at web.de
Sun May 1 08:34:01 EDT 2005
George Sakkis wrote:
> Though not the fastest to execute; using concatenate instead of
> initializing an array from a list [a,a] is more than 2,5 time faster in
> my system (~4.6 vs 11.8 usec per loop according to timeit.py), and it's
> not harder either.
That surprises me. I would expect essentially the same amount of
data-shuffling.
> One difference is that the equivalent expression for
> concatenate expects arrays of shape (1,len(a)) instead of 1D arrays os
> shape (len(a),):
If you want to start out with 1D arrays, just reorder the operations:
>>> a = array(range(5))
>>> reshape(concatenate((a, a)), (2, 5))
array([[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4]])
>>>
Peter
More information about the Python-list
mailing list