> > > > The idiomatic way of doing this for numpy arrays would be: > > def test2(arrx): > return (arrx >= 10).sum() > > Even this versions takes more time to run than my original python version > with arrays.
>>> def test3(listx): ... return (listx>=10).sum() >>> t = timeit.Timer("test3(list2)","from __main__ import *") >>> t.timeit() 7.146049976348877 My fastest version at the moment is: def test3(listx): ... return len(numpy.where(listx>=10)[0]) >>> t = timeit.Timer("test3(list2)","from __main__ import *") <timeit-src>:2: SyntaxWarning: import * only allowed at module level >>> t.timeit() 5.8264470100402832 Thank you. All the best, Bruno
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion