
July 23, 2010
5:37 a.m.
On Thu, Jul 22, 2010 at 5:09 PM, marco cammarata <marcocamma@gmail.com> wrote:
Hi,
any idea why the simple code below is so slow ?
import numpy as n from time import time as t
dims = (640,480) m = n.random.random( dims )
l=[]
for i in range(200): l.append(m)
t0=t() b=n.array(l) print t()-t0
To convert the list into an array takes about 5 sec ...
There was a recent thread that covers similar ground. "Stacking arrays along new dimension in front" http://www.mail-archive.com/numpy-discussion@scipy.org/msg26772.html I think the fastest way was to do b = n.concatenate(a_[None] for a_ in l) but I could be mistaken, and there should probably be a more general solution to this problem. Skipper