[Numpy-discussion] Is there a more efficient way to do this?

Laszlo Nagy gandalf@shopzeus....
Wed Aug 8 15:46:15 CDT 2012


>
> In [4]: timeit get_slices_slow(data)
> 100 loops, best of 3: 3.51 ms per loop
>
> In [5]: timeit get_slices_fast(data)
> 1000 loops, best of 3: 1.76 ms per loop
>
> In [6]: timeit get_slices_faster(data)
> 10000 loops, best of 3: 116 us per loop
>
> So using the fast bincount and array indexing methods gets you about a
> factor of 30 improvement.  Even just doing the counting in a loop with
> good indexing will get you a factor of 2.
Fantastic, thank you! I do no fully understand your code yet. But I'm 
going to read all related docs. :-)


More information about the NumPy-Discussion mailing list