News for hackers. Stuff that matters.
Re:How slow is Python really? Or how fast is your language? by omaranto on Wednesday April 30, 2014 @08:43AM (#7672873)
Well, this particular example shows instead that the overhead of calling libraries written in other languages can be so large that a pure python solution can be faster. The current top answer to the question shows a pure python version that is about 20 times faster, commenters explain that the arrays are so small that the overhead in calling numpy outweighs any avantage numpy's speed gives.

http://codegolf.stackexchange.com/a/26337/3074

Re:How slow is Python really? Or how fast is your language? by algorias on Wednesday April 30, 2014 @09:29AM (#7673108)
That 20x is hardly just because of numpy overhead, read the answer more carefully:

> optimization by precomputing F values

> I also optimize by skipping the rest of the convolution if the first result isn't zero.

If you don't measure implementations of the same algorithm, you hardly have a fair language/library benchmark.

Re:How slow is Python really? Or how fast is your language? by kbenson on Wednesday April 30, 2014 @10:18AM (#7673433)
Measuring implementations of the same algorithm is how you benchmark algorithms, not a a language as a whole. If a language or library allows for enhancements based on it's strengths (in this case, the ability to code in early exits), those are perfectly valid in benchmarking languages and libraries.

Put another way, one of the benefits of Python (and drawbacks of using an external library) is that you have more control over the algorithm and exactly what it does.

That said, a sample size of one will hardly give you an accurate picture.

Re:How slow is Python really? Or how fast is your language? by igouy on Wednesday April 30, 2014 @11:18AM (#7673843)
"Measuring implementations of the same algorithm is how you benchmark" that one algorithm.

"Measuring implementations of [different] algorithms is how you benchmark algorithms"

Re:How slow is Python really? Or how fast is your language? by kbenson on Wednesday April 30, 2014 @11:54AM (#7674144)
Yes, and in this case, we can think of pure Python and it's capabilities as one "algorithm", and calling out to a library as another.
Re:How slow is Python really? Or how fast is your language? by igouy on Wednesday April 30, 2014 @12:53PM (#7674542)
That is probably not what readers of your comment understand by the word algorithm.
Re:How slow is Python really? Or how fast is your language? by omaranto on Wednesday April 30, 2014 @02:40PM (#7675378)
You're right, I wasn't careful. Without precomputing F, the speedup is only around 7x.