15.02.2012 00:23, Marcel Oliver kirjoitti:
[clip]
> Thanks for all the replies.  Playing a bit with timeit, it is clear
> that it cannot just be the overhead of checking the type of the index
> array, as the overhead grows very roughly propertional to the size of
> the index array, but remains independent of the size of the indexed
> array.
> 
> In [1]: a=arange(1000000)
> 
> In [2]: i = arange(10)
> 
> In [3]: timeit a[i]
> 100000 loops, best of 3: 1.95 us per loop
> 
> In [4]: i = arange(100)
> 
> In [5]: timeit a[i]
> 100000 loops, best of 3: 4.07 us per loop

I think the linear growth here is expected, as

i = arange(n)
a[i].shape == i.shape

It's probably possible to cut the overhead, though.

-- 
Pauli Virtanen

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to