[Numpy-discussion] A surprising result from benchmarking
Sun Mar 11 00:02:13 CST 2007
I'm new to numpy, and I'm finding it hard to predict what is fast in
python/numpy and what is slow. The following seems puzzling: I am doing the
same thing an ugly way and a cleaner way. But the ugly map/lambda/filter
expression is 15x faster than using numpy's internals.
Can anyone explain why? For now, this makes me nervous about incorporating
basic numpy functionality into real programs.
---Code starts here---
from numpy import matrix
greaterPerLine=[sum(x) for x in highEnough]
print("method 1 took %f seconds"%elapsed1)
print("method 2 took %f seconds"%elapsed2)
---Output starts here---
method 1 took 3.566760 seconds
method 2 took 0.232356 seconds
Thanks so much!
More information about the Numpy-discussion